Status: New
Owner: ----
CC: [email protected]
Labels: Type-Defect Priority-Medium Quantum

New issue 2974 by [email protected]: Bug in sympy.physics.quantum "qapply"
http://code.google.com/p/sympy/issues/detail?id=2974

(Note: this was originally reported at https://github.com/sympy/sympy/issues/945)

There seems to be a bug in `qapply`, both in 0.7.1 and in the current git HEAD. I was triggering it when trying `qapply(vacuum.dual*A)` , where `vacuum.dual` is a custom Bra-class that I'm hacking on, and A is a quantum operator. I am not sure if my Bra-class does indeed conform to what is required for such, but I believe the bug is independent from that. The main requirements are that the two objects are non-commutative things that do not know how to be applied to each other (i.e. `lhs._apply_operator(rhs)` and vice versa fails). In this case `qapply_Mul` will continue to try the previous pair in the multiplication via line 166 of `qapply.py`:
```
    return qapply_Mul(e._new_rawargs(*(args+[lhs])), **options)*rhs
```
Now if this was actually the first pair of the multiplication, `e._new_rawargs(*(args+[lhs]))` will return `lhs` itself (might this be the bug indeed?). The new call of `qapply_Mul` will then work on the `lhs` object, assuming it is `Mul`, which it isn't. It probably most often goes unnoticed since it has a high chance of bailing out early either due to `lhs` not having two arguments or one of them being commutative. The solution should probably be simple, just check for for an empty `args` at that line. A testcase will need a lefthandside object that is not commutative and at least two non-commutative arguments. I was unable to find a good example, and my quick try at a simple example Bra-class was not successful.

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" 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-issues?hl=en.

Reply via email to