Ticket #10064 (positive_review defect)
-1 in expression "is_positive".
| Reported by: | fmaltey | Owned by: | burcin |
|---|---|---|---|
| Priority: | critical | Milestone: | sage-pending |
| Component: | calculus | Keywords: | sd35 |
| Cc: | robertwb, kcrisman | Work issues: | |
| Report Upstream: | N/A | Reviewers: | Burcin Erocal |
| Authors: | Mike Hansen | Merged in: | |
| Dependencies: | #7160 | Stopgaps: |
Description (last modified by burcin) (diff)
I test :
y = I*I*x / x # so y is the expression -1 y._is_positive() # the answer is True (and I dislike) z = -x / x z._is_positive() # the answer is False bool (z == y) # the answer is True
Apply attachment:trac_10064.patch.
Attachments
Change History
comment:2 Changed 3 years ago by burcin
- Cc robertwb added
- Priority changed from major to critical
- Status changed from new to needs_review
- Authors set to Burcin Erocal
attachment:trac_10064-compare_I.patch changes the quadratic number field element comparison code to return a more sensible result. Now we have:
sage: m = (I*I).pyobject() sage: m > 0 False sage: m < 0 True
This also fixes #10062.
comment:3 Changed 3 years ago by jgaski
- Status changed from needs_review to needs_work
Here is a small bit of code that breaks (in 4.5.3) with trac_10064-compare_I.patch applied:
K.<a> = QuadraticField(5) E = EllipticCurve(K,[-1, -1, 1/2*a + 1/2, -1/2*a - 1/2, 1/2*a + 1/2]) E.torsion_subgroup()
comment:4 Changed 3 years ago by jgaski
Please see http://tinypaste.com/3f27d for the error from the above code snippet.
comment:6 Changed 2 years ago by kcrisman
Apparently related to #7160 and #6132, see this sage-devel discussion.
comment:7 Changed 17 months ago by mhansen
- Status changed from needs_work to needs_review
- Dependencies set to 7160
- Authors changed from Burcin Erocal to Mike Hansen
I've added a patch which verifies that is fixed by #7160.
Apply trac_10064.patch
comment:10 Changed 17 months ago by burcin
- Status changed from needs_review to positive_review
- Reviewers set to Burcin Erocal
- Description modified (diff)
- Milestone changed from sage-4.8 to sage-5.0
Looks good to me.
Note: See
TracTickets for help on using
tickets.


Simpler example:
The is_positive() test in pynac is at line 923 in numeric.cpp:
case PYOBJECT: n = is_real() && (PyObject_Compare(v._pyobject, ZERO) > 0); if (PyErr_Occurred()) py_error("is_positive"); return n;We use the python comparison. Unfortunately, this doesn't work as expected for number field elements: