If as_independent (or any other function) does not work with noncommutative symbols, it's a bug, and should be fixed.
Unfortunately, quite a few functions in SymPy are not written with noncommutative symbols taken into consideration. This is because most people and most code does not use them. However, it should not be this way. Every function should either give the correct result for a noncommutative expression, or raise NotImplementedError if it cannot (for example, factor() does this). I recommend opening an issue for this. Someone might come along and fix it for you (Chris does a lot of work on making these methods of Expr work with noncommutatives for example), but likely you will need to fix it yourself. You should look at the code to see which part of it makes an assumption that is invalid in the noncommutative case, and fix it. You may need to rewrite the algorithm, or write a separate algorithm for the noncommutative case, depending on how ingrained the assumption of commutativity is in the code. Or, for example, if an algorithm that takes noncommutatives into consideration would be slower in the commutative case, you should separate the code. The code should be well tested (especially if it's being used by other functions like integrate()), so don't worry about breaking things. Just make sure that the tests pass, and you can be pretty sure that things still work for the commutative case (you will of course need to add your own tests for the noncommutative case). Aaron Meurer On Wed, Jul 6, 2011 at 12:57 PM, Tom Bachmann <[email protected]> wrote: > I think as_independent only works with commutative terms (i.e. any > implementation for non-commutative terms that ever existed is now somehow > broken). Indeed when I started my project some objects were non-commutative > [Tuple lacking correct assumptions turned out to be the cause] and I got > similar behaviour. > > I guess this is not very helpful, since you cannot just make your > non-commutative objects commutative ^^. > > -- > 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. > > -- 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.
