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
In [17]: Piecewise((1, Lt(1, 2, evaluate=False)), (2, True))
---------------------------------------------------------------------------TypeError: Invalidcomparisonofnon-realzoo
This is dues to the _canonical_coeff function somehow making incorrect presumptions about the relational:
ipdb> ll
46 def _canonical_coeff(rel):
47 # return -2*x + 1 < 0 as x > 1/2
48 # XXX make this part of Relational.canonical?
49 rel = rel.canonical
50 if not rel.is_Relational or rel.rhs.is_Boolean:
51 return rel # Eq(x, True)
52 b, l = rel.lhs.as_coeff_Add(rational=True)
53 m, lhs = l.as_coeff_Mul(rational=True)
54 rhs = (rel.rhs - b)/m
55 if m < 0:
56 return rel.reversed.func(lhs, rhs)
---> 57 return rel.func(lhs, rhs)
58
ipdb> p m
0
ipdb> p rhs
zoo
The text was updated successfully, but these errors were encountered:
Can we change the definition of _canonical_coeff with respect to relational ?
But when we write the1<2 instead of Lt(1, 2, evaluate=False) it doesn't give any error!
In [3] : Piecewise((1,1<2), (2, True))
Out[4] : 1
How should I move forward for opening the PR for that?
line 53 above could be changed to m, lhs = l.as_coeff_Mul(rational=True) if l else S.One, l. I wish S.Zero.as_coeff_Mul() gave (1,0) instead of (0, 1)...but that is a way to work around it.
This is dues to the
_canonical_coeff
function somehow making incorrect presumptions about the relational:The text was updated successfully, but these errors were encountered: