Opened 4 years ago
Closed 4 years ago
#24380 closed defect (fixed)
sympy misbehavoir
Reported by:  vdelecroix  Owned by:  

Priority:  major  Milestone:  sage8.2 
Component:  packages: standard  Keywords:  
Cc:  jdemeyer, fbissey  Merged in:  
Authors:  Vincent Delecroix  Reviewers:  Ralf Stephan 
Report Upstream:  Fixed upstream, but not in a stable release.  Work issues:  
Branch:  4238d34 (Commits, GitHub, GitLab)  Commit:  4238d34282fb80c302c57bacfec0a2c17bfe6e8a 
Dependencies:  Stopgaps: 
Description (last modified by )
Sympy polyomials with Sage real number coefficients look very broken
sage: import sympy, sympy.polys sage: x = sympy.Symbol('x') sage: p = sympy.polys.Poly(x**2  2.0) sage: p <repr(<sympy.polys.polytools.Poly at 0x7f92ca50ef18>) failed: TypeError: int() argument must be a string or a number, not 'NoneType'> sage: p.coeffs() TypeError Traceback (most recent call last) <ipythoninput247e7e3b79f346> in <module>() > 1 p.coeffs() /opt/sage/local/lib/python2.7/sitepackages/sympy/polys/polytools.pyc in coeffs(f, order) 795 796 """ > 797 return [f.rep.dom.to_sympy(c) for c in f.rep.coeffs(order=order)] 798 799 def monoms(f, order=None): /opt/sage/local/lib/python2.7/sitepackages/sympy/polys/domains/realfield.pyc in to_sympy(self, element) 64 def to_sympy(self, element): 65 """Convert ``element`` to SymPy number. """ > 66 return Float(element, self.dps) 67 68 def from_sympy(self, expr): /opt/sage/local/lib/python2.7/sitepackages/sympy/core/numbers.pyc in __new__(cls, num, dps, prec, precision) 1053 _mpf_ = mpf_norm(_mpf_, precision) 1054 else: > 1055 _mpf_ = mpmath.mpf(num, prec=prec)._mpf_ 1056 1057 # special cases /opt/sage/src/sage/libs/mpmath/ext_main.pyx in sage.libs.mpmath.ext_main.mpf.__init__ (build/cythonized/sage/libs/mpmath/ext_main.c:23448)() 1886 opts = global_opts 1887 if kwargs: > 1888 if 'prec' in kwargs: opts.prec = int(kwargs['prec']) 1889 if 'dps' in kwargs: opts.prec = libmp.dps_to_prec(int(kwargs['dps'])) 1890 if 'rounding' in kwargs: opts.rounding = rndmode_from_python(kwargs['rounding']) TypeError: int() argument must be a string or a number, not 'NoneType'
We backport a patch in sympy development branch. This problem was originally found from digging around #24378. Upstream fix is at https://github.com/sympy/sympy/pull/13276
Change History (12)
comment:1 Changed 4 years ago by
 Description modified (diff)
 Summary changed from sympy misbehavoir with gmpy2 installed to sympy misbehavoir (with gmpy2 installed)
comment:2 Changed 4 years ago by
comment:3 Changed 4 years ago by
 Branch set to u/vdelecroix/24380
 Commit set to 3e423f02882555ea84ad8100201caf203c524922
 Report Upstream changed from Not yet reported upstream; Will do shortly. to Fixed upstream, but not in a stable release.
 Status changed from new to needs_review
New commits:
3e423f0  24380: sympy ackport in core/numbers.py

comment:4 Changed 4 years ago by
 Commit changed from 3e423f02882555ea84ad8100201caf203c524922 to 459c93aef0b14caa722eff807238dbf9e77a16d6
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
459c93a  24380: sympy backport in core/numbers.py

comment:5 Changed 4 years ago by
 Description modified (diff)
 Summary changed from sympy misbehavoir (with gmpy2 installed) to sympy misbehavoir
comment:6 Changed 4 years ago by
 Commit changed from 459c93aef0b14caa722eff807238dbf9e77a16d6 to be1417d0a5f8169c4c0cb3889864deeb565d9250
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
be1417d  24380: sympy backport in core/numbers.py

comment:7 Changed 4 years ago by
 Cc fbissey added
comment:8 Changed 4 years ago by
 Commit changed from be1417d0a5f8169c4c0cb3889864deeb565d9250 to 4238d34282fb80c302c57bacfec0a2c17bfe6e8a
Branch pushed to git repo; I updated commit sha1. New commits:
4238d34  24380: bump sympy package version

comment:9 Changed 4 years ago by
 Reviewers set to Ralf Stephan
 Status changed from needs_review to positive_review
LGTM.
comment:10 Changed 4 years ago by
Not changing the status, but would you mind adding upstream info about this? Issues number and/or PR number.
comment:11 Changed 4 years ago by
 Description modified (diff)
OK, found it myself and added to description for future reference.
comment:12 Changed 4 years ago by
 Branch changed from u/vdelecroix/24380 to 4238d34282fb80c302c57bacfec0a2c17bfe6e8a
 Resolution set to fixed
 Status changed from positive_review to closed
Updating sympy to the development version makes it working