Hi, I am continuing some work that Ondrej and I started this week implementing quantum operators in sympy. I am building a Dagger class that does the hermitian conjugate. In the canonize method, the Dagger operator need to test what type of object has been passed to Dagger. >From there it 1) either actually takes the dagger if it knows how or 2) just leaves Dagger unevaluated. So, I need to test for various types of objects.
The common way of testing the type of object you get in sympy is to use the attributes like is_number, is_real, etc. But, I have two, no three problems with this: 1. Only subclasses of Basic have these attributes. Matrices (and any other immutable type) don't inherit from Basic and so they don't have all these attributes. 2. There is no is_complex attribute in basic. This brings up another ?: how are complex number represented in sympy? 3. For custom object types, like my operators, I have to add custom code to my Dagger class that does things like: if isinstance(QuantumOperator): # take Dagger of operator Is this the best way of going about this? Cheers, Brian --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---
