-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot determine truth value of Relational while simplifying expression #24045
Labels
Comments
I think this is a bug in In [15]: l = [(((10, 0, 'tuple'), (2, (((3, 1, 'Add'), (2, (((3, 0, 'Mul'), (2, (((2, 0, 'Symbol'), (1, (
...: 'a',)), ((1, 0, 'Number'), (0, ()), (), 1), 1), ((2, 0, 'Symbol'), (1, ('c',)), ((1, 0, 'Number'
...: ), (0, ()), (), 1), 1))), ((1, 0, 'Number'), (0, ()), (), 1), 1), ((3, 0, 'Mul'), (2, (((2, 0, '
...: Symbol'), (1, ('b',)), ((1, 0, 'Number'), (0, ()), (), 1), 1), ((2, 0, 'Symbol'), (1, ('c',)), (
...: (1, 0, 'Number'), (0, ()), (), 1), 1))), ((1, 0, 'Number'), (0, ()), (), 1), -1))), ((1, 0, 'Num
...: ber'), (0, ()), (), 1), 1), ((10, 0, 'list'), (1, (((1, 0, 'Number'), (0, ()), (), -1),)), ((1,
...: 0, 'Number'), (0, ()), (), 1), 1))), ((1, 0, 'Number'), (0, ()), (), 1), 1), [(a*c - b*c, [-1])]
...: ), (((10, 0, 'tuple'), (2, (((3, 1, 'Add'), (2, (((3, 0, 'Mul'), (2, (((2, 0, 'Symbol'), (1, ('a
...: ',)), ((1, 0, 'Number'), (0, ()), (), 1), 1), ((2, 0, 'Symbol'), (1, ('c',)), ((1, 0, 'Number'),
...: (0, ()), (), 1), 1))), ((1, 0, 'Number'), (0, ()), (), 1), 1.00000000000000), ((3, 0, 'Mul'), (
...: 2, (((2, 0, 'Symbol'), (1, ('b',)), ((1, 0, 'Number'), (0, ()), (), 1), 1), ((2, 0, 'Symbol'), (
...: 1, ('c',)), ((1, 0, 'Number'), (0, ()), (), 1), 1))), ((1, 0, 'Number'), (0, ()), (), 1), -1.000
...: 00000000000))), ((1, 0, 'Number'), (0, ()), (), 1), 1), ((10, 0, 'list'), (1, (((1, 0, 'Number')
...: , (0, ()), (), -1),)), ((1, 0, 'Number'), (0, ()), (), 1), 1))), ((1, 0, 'Number'), (0, ()), (),
...: 1), 1), [(1.0*a*c - 1.0*b*c, [-1])])]
...:
In [16]: sorted(l)
TypeError: cannot determine truth value of Relational The two elements of this list should be orderable but the problem is that the floats and integers compare equal: In [17]: l[0]
Out[17]:
(((10, 0, 'tuple'),
(2,
(((3, 1, 'Add'),
(2,
(((3, 0, 'Mul'),
(2,
(((2, 0, 'Symbol'),
(1, ('a',)),
((1, 0, 'Number'), (0, ()), (), 1),
1),
((2, 0, 'Symbol'),
(1, ('c',)),
((1, 0, 'Number'), (0, ()), (), 1),
1))),
((1, 0, 'Number'), (0, ()), (), 1),
1),
((3, 0, 'Mul'),
(2,
(((2, 0, 'Symbol'),
(1, ('b',)),
((1, 0, 'Number'), (0, ()), (), 1),
1),
((2, 0, 'Symbol'),
(1, ('c',)),
((1, 0, 'Number'), (0, ()), (), 1),
1))),
((1, 0, 'Number'), (0, ()), (), 1),
-1))),
((1, 0, 'Number'), (0, ()), (), 1),
1),
((10, 0, 'list'),
(1, (((1, 0, 'Number'), (0, ()), (), -1),)),
((1, 0, 'Number'), (0, ()), (), 1),
1))),
((1, 0, 'Number'), (0, ()), (), 1),
1),
[(a*c - b*c, [-1])])
In [18]: l[1]
Out[18]:
(((10, 0, 'tuple'),
(2,
(((3, 1, 'Add'),
(2,
(((3, 0, 'Mul'),
(2,
(((2, 0, 'Symbol'),
(1, ('a',)),
((1, 0, 'Number'), (0, ()), (), 1),
1),
((2, 0, 'Symbol'),
(1, ('c',)),
((1, 0, 'Number'), (0, ()), (), 1),
1))),
((1, 0, 'Number'), (0, ()), (), 1),
1.0),
((3, 0, 'Mul'),
(2,
(((2, 0, 'Symbol'),
(1, ('b',)),
((1, 0, 'Number'), (0, ()), (), 1),
1),
((2, 0, 'Symbol'),
(1, ('c',)),
((1, 0, 'Number'), (0, ()), (), 1),
1))),
((1, 0, 'Number'), (0, ()), (), 1),
-1.0))),
((1, 0, 'Number'), (0, ()), (), 1),
1),
((10, 0, 'list'),
(1, (((1, 0, 'Number'), (0, ()), (), -1),)),
((1, 0, 'Number'), (0, ()), (), 1),
1))),
((1, 0, 'Number'), (0, ()), (), 1),
1),
[(1.0*a*c - 1.0*b*c, [-1])]) Related to this: In [19]: list(ordered([1, 1.0]))
Out[19]: [1, 1.0]
In [20]: list(ordered([1.0, 1]))
Out[20]: [1.0, 1] The problem is that there is no tie-breaker rule to distinguish floats from rationals. |
smichr
added a commit
to smichr/sympy
that referenced
this issue
Sep 24, 2023
smichr
added a commit
to smichr/sympy
that referenced
this issue
Sep 24, 2023
smichr
added a commit
to smichr/sympy
that referenced
this issue
Sep 24, 2023
smichr
added a commit
to smichr/sympy
that referenced
this issue
Sep 24, 2023
smichr
added a commit
to smichr/sympy
that referenced
this issue
Sep 26, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For a moderately simple expression, sympy>=1.11 throws an exception when simplifying. Small (minimal?) reproducer:
The offending subexpression is:
This works fine on sympy<=1.10. The cause was tracked down props to @pnbabu: earlier sympy used
sorted(d.keys())
whereas the current release usessorted(d.items())
while sorting a dictionaryd
created internally bypowsimp()
:0ca399d#diff-18021242f0d8c835ef8fa3190d8379ab5cb7ca45c31a75fffbc65d1f0f36797fL296
The text was updated successfully, but these errors were encountered: