You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
The text was updated successfully, but these errors were encountered:
(Note: this was originally reported at #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)
, wherevacuum.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 caseqapply_Mul
will continue to try the previous pair in the multiplication via line 166 ofqapply.py
:Now if this was actually the first pair of the multiplication,
e._new_rawargs(*(args+[lhs]))
will returnlhs
itself (might this be the bug indeed?). The new call ofqapply_Mul
will then work on thelhs
object, assuming it isMul
, which it isn't. It probably most often goes unnoticed since it has a high chance of bailing out early either due tolhs
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.
The text was updated successfully, but these errors were encountered: