Opened 13 months ago
Closed 13 months ago
#32185 closed defect (fixed)
Failing weak order assertion on random symbolic expression
Reported by:  ghkliem  Owned by:  

Priority:  major  Milestone:  sage9.4 
Component:  symbolics  Keywords:  pi, random doctests 
Cc:  Merged in:  
Authors:  Michael Orlitzky  Reviewers:  Travis Scrimshaw 
Report Upstream:  N/A  Work issues:  
Branch:  551d3ae (Commits, GitHub, GitLab)  Commit:  551d3ae99249456904eb6d2cdc97dbe9ed6201b9 
Dependencies:  Stopgaps: 
Description (last modified by )
File "src/sage/symbolic/random_tests.py", line 430, in sage.symbolic.random_tests.test_symbolic_expression_order Failed example: test_symbolic_expression_order(10000) # long time Exception raised: Traceback (most recent call last): File "/srv/public/kliem/sage/local/lib/python3.7/sitepackages/sage/doctest/forker.py", line 718, in _run self.compile_and_execute(example, compiler, test.globs) File "/srv/public/kliem/sage/local/lib/python3.7/sitepackages/sage/doctest/forker.py", line 1137, in compile_and_execute exec(compiled, globs) File "<doctest sage.symbolic.random_tests.test_symbolic_expression_order[2]>", line 1, in <module> test_symbolic_expression_order(Integer(10000)) # long time File "/srv/public/kliem/sage/local/lib/python3.7/sitepackages/sage/symbolic/random_tests.py", line 456, in test_symbolic_expression_order assert_strict_weak_order(a, b, c, mixed_order) File "/srv/public/kliem/sage/local/lib/python3.7/sitepackages/sage/symbolic/random_tests.py", line 387, in assert_strict_weak_order cmp_M[i, j] = (cmp_func(x[i], x[j]) == 1) # or 1, doesn't matter File "sage/symbolic/comparison.pyx", line 228, in sage.symbolic.comparison.mixed_order (build/cythonized/sage/symbolic/comparison.cpp:4349) cpdef int mixed_order(lhs, rhs) except 2: File "sage/symbolic/comparison.pyx", line 268, in sage.symbolic.comparison.mixed_order (build/cythonized/sage/symbolic/comparison.cpp:4126) less_than = _mixed_key(lhs) < _mixed_key(rhs) File "sage/symbolic/comparison.pyx", line 355, in sage.symbolic.comparison._mixed_key.__lt__ (build/cythonized/sage/symbolic/comparison.cpp:5238) return det_ex < 0 TypeError: '<' not supported between instances of 'Pi' and 'int' ********************************************************************** 1 item had failures: 2 of 4 in sage.symbolic.random_tests.test_symbolic_expression_order [49 tests, 2 failures, 3.59 s]
The underlying problem is the following:
sage: pi = sage.symbolic.constants.Pi() sage: pi < 0  TypeError Traceback (most recent call last) <ipythoninput7f23f08971c70> in <module> > 1 pi < Integer(0) /srv/public/kliem/sage/local/lib/python3.7/sitepackages/sage/rings/integer.pyx in sage.rings.integer.Integer.__richcmp__ (build/cythonized/sage/rings/integer.c:7888)() 947 c = mpz_cmp_d((<Integer>left).value, d) 948 else: > 949 return coercion_model.richcmp(left, right, op) 950 951 return rich_to_bool_sgn(op, c) /srv/public/kliem/sage/local/lib/python3.7/sitepackages/sage/structure/coerce.pyx in sage.structure.coerce.CoercionModel.richcmp (build/cythonized/sage/structure/coerce.c:20854)() 2006 raise bin_op_exception('<=', x, y) 2007 elif op == Py_GT: > 2008 raise bin_op_exception('>', x, y) 2009 else: 2010 raise bin_op_exception('>=', x, y) TypeError: unsupported operand parent(s) for >: 'Integer Ring' and '<class 'sage.symbolic.constants.Pi'>'
Change History (6)
comment:1 Changed 13 months ago by
 Description modified (diff)
comment:2 Changed 13 months ago by
 Branch set to u/mjo/ticket/32185
 Commit set to b30ce37a7e11ed6c871d7167737ef1fb932ab31c
 Status changed from new to needs_review
comment:3 Changed 13 months ago by
 Commit changed from b30ce37a7e11ed6c871d7167737ef1fb932ab31c to 551d3ae99249456904eb6d2cdc97dbe9ed6201b9
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
551d3ae  Trac #32185: special case constant symbolic relations.

comment:4 Changed 13 months ago by
Tests pass. I dropped the two commits from #32243 that I left in there by mistake.
comment:5 Changed 13 months ago by
 Reviewers set to Travis Scrimshaw
 Status changed from needs_review to positive_review
LGTM.
comment:6 Changed 13 months ago by
 Branch changed from u/mjo/ticket/32185 to 551d3ae99249456904eb6d2cdc97dbe9ed6201b9
 Resolution set to fixed
 Status changed from positive_review to closed
Note: See
TracTickets for help on using
tickets.
I wasn't able to reproduce the failure, but I'm pretty sure that
Pi
is arising frompi.pyobject()
during the comparison. In any case, it looks like I've fixed at least one bug. I'll test the new branch overnight.New commits:
Trac #32243: patch gfan to look for cddlib headers in new location.
Trac #32243: look for cddlib0.94m headers in the right place.
Trac #32185: special case constant symbolic relations.