This is not a Sage problem, it's a mpmath 1.2 issue, which broke Sage 
detection when using distro packages. You either need to revert commit [1] 
or set the MPMATH_SAGE env variable.

[1] https://github.com/fredrik-johansson/mpmath/commit/84ca137f

El domingo, 17 de octubre de 2021 a las 0:26:16 UTC+2, [email protected] 
escribió:

> Hi there,
>
> I am using sagemath 9.2-2 installed with apt on PopOs 21.04. When I try to 
> evaluate `Si(pi).n()` I get the following error:
> --------------------------------------------------------------------------- 
> TypeError Traceback (most recent call last) 
> /usr/lib/python3/dist-packages/sage/symbolic/expression.pyx in 
> sage.symbolic.expression.Expression.numerical_approx 
> (build/cythonized/sage/symbolic/expression.cpp:35783)() 6069 try: -> 6070 x 
> = x._convert(kwds) 6071 except TypeError: # numerical approximation for 
> real number failed 
> /usr/lib/python3/dist-packages/sage/symbolic/expression.pyx in 
> sage.symbolic.expression.Expression._convert 
> (build/cythonized/sage/symbolic/expression.cpp:10297)() 1464 """ -> 1465 cdef 
> GEx res = self._gobj.evalf(0, kwds) 1466 return new_Expression_from_GEx(
> self._parent, res) 
> /usr/lib/python3/dist-packages/sage/functions/exp_integral.py in 
> _evalf_(self, 
> z, parent, algorithm) 868 import mpmath --> 869 return mpmath_utils_call(
> mpmath.si, z, parent=parent) 870 
> /usr/lib/python3/dist-packages/sage/libs/mpmath/utils.pyx in 
> sage.libs.mpmath.utils.call 
> (build/cythonized/sage/libs/mpmath/utils.c:7121)() 438 mp.prec = orig --> 
> 439 y = mpmath_to_sage(y, prec) 440 if parent is None: 
> /usr/lib/python3/dist-packages/sage/libs/mpmath/utils.pyx in 
> sage.libs.mpmath.utils.mpmath_to_sage 
> (build/cythonized/sage/libs/mpmath/utils.c:5511)() 271 y = RealField(prec)
> () --> 272 mpfr_from_mpfval(y.value, x._mpf_) 273 return y 
> /usr/lib/python3/dist-packages/sage/libs/mpmath/utils.pyx in 
> sage.libs.mpmath.utils.mpfr_from_mpfval 
> (build/cythonized/sage/libs/mpmath/utils.c:4695)() 166 cdef long bc --> 
> 167 sign, man, exp, bc = x 168 if man: TypeError: Cannot convert mpz to 
> sage.rings.integer.Integer During handling of the above exception, another 
> exception occurred: TypeError Traceback (most recent call last) 
> <ipython-input-15-6561919e4fcc> in <module> ----> 1 Si(pi).n() 
> /usr/lib/python3/dist-packages/sage/structure/element.pyx in 
> sage.structure.element.Element.n 
> (build/cythonized/sage/structure/element.c:8382)() 883 0.666666666666667 
> 884 """ --> 885 return self.numerical_approx(prec, digits, algorithm) 886 
> 887 def _mpmath_(self, prec=53, rounding=None): 
> /usr/lib/python3/dist-packages/sage/symbolic/expression.pyx in 
> sage.symbolic.expression.Expression.numerical_approx 
> (build/cythonized/sage/symbolic/expression.cpp:35856)() 6072 pass # try 
> again with complex 6073 kwds['parent'] = R.complex_field() -> 6074 x = x.
> _convert(kwds) 6075 6076 # we have to consider constants as well, since 
> infinity is a constant 
> /usr/lib/python3/dist-packages/sage/symbolic/expression.pyx in 
> sage.symbolic.expression.Expression._convert 
> (build/cythonized/sage/symbolic/expression.cpp:10297)() 1463 0 1464 """ -> 
> 1465 cdef GEx res = self._gobj.evalf(0, kwds) 1466 return 
> new_Expression_from_GEx(self._parent, res) 1467 
> /usr/lib/python3/dist-packages/sage/functions/exp_integral.py in 
> _evalf_(self, 
> z, parent, algorithm) 867 """ 868 import mpmath --> 869 return 
> mpmath_utils_call(mpmath.si, z, parent=parent) 870 871 def _derivative_(
> self, z, diff_param=None): 
> /usr/lib/python3/dist-packages/sage/libs/mpmath/utils.pyx in 
> sage.libs.mpmath.utils.call 
> (build/cythonized/sage/libs/mpmath/utils.c:7121)() 437 finally: 438 mp.prec 
> = orig --> 439 y = mpmath_to_sage(y, prec) 440 if parent is None: 441 
> return y /usr/lib/python3/dist-packages/sage/libs/mpmath/utils.pyx in 
> sage.libs.mpmath.utils.mpmath_to_sage 
> (build/cythonized/sage/libs/mpmath/utils.c:5511)() 270 if hasattr(x, 
> "_mpf_"): 271 y = RealField(prec)() --> 272 mpfr_from_mpfval(y.value, x.
> _mpf_) 273 return y 274 elif hasattr(x, "_mpc_"): 
> /usr/lib/python3/dist-packages/sage/libs/mpmath/utils.pyx in 
> sage.libs.mpmath.utils.mpfr_from_mpfval 
> (build/cythonized/sage/libs/mpmath/utils.c:4695)() 165 cdef long exp 166 
> cdef long bc --> 167 sign, man, exp, bc = x 168 if man: 169 mpfr_set_z(res
> , man.value, MPFR_RNDZ) TypeError: Cannot convert mpz to 
> sage.rings.integer.Integer
> --------------------------------------------------------------------------- 
>
> I believe this should be able to be approximated numerically and should 
> return approximately 1.851937
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/d9119676-07f5-4fed-bd9c-920fdc51767dn%40googlegroups.com.

Reply via email to