I don't understand this behavior:
Python 3.5.1 |Continuum Analytics, Inc.| (default, Dec 7 2015, 11:16:01)
Type "copyright", "credits" or "license" for more information.
IPython 4.1.2 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: from sympy import *
In [2]: phi = symbols('phi', cls=Function)
In [3]: t = symbols('t')
In [4]: phi(t).xreplace({t: 0})
Out[4]: phi(0)
In [5]: phi(t).xreplace({t: 0.0})
Out[5]: 1.61803398874989
In [6]: phi(t).xreplace({t: 5.0})
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/home/moorepants/miniconda3/lib/python3.5/site-packages/sympy/core/evalf.py
in evalf(x, prec, options)
1209 try:
-> 1210 rf = evalf_table[x.func]
1211 r = rf(x, prec, options)
KeyError: phi
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
<ipython-input-6-ec5c48b4cb2f> in <module>()
----> 1 phi(t).xreplace({t: 5.0})
/home/moorepants/miniconda3/lib/python3.5/site-packages/sympy/core/basic.py
in xreplace(self, rule)
1086 args = tuple(args)
1087 if not _aresame(args, self.args):
-> 1088 return self.func(*args)
1089 return self
1090
/home/moorepants/miniconda3/lib/python3.5/site-packages/sympy/core/function.py
in __new__(cls, *args, **options)
683 def __new__(cls, *args, **options):
684 args = list(map(sympify, args))
--> 685 obj = super(AppliedUndef, cls).__new__(cls, *args,
**options)
686 return obj
687
/home/moorepants/miniconda3/lib/python3.5/site-packages/sympy/core/function.py
in __new__(cls, *args, **options)
380 pr2 = min(cls._should_evalf(a) for a in result.args)
381 if pr2 > 0:
--> 382 return result.evalf(mlib.libmpf.prec_to_dps(pr))
383 return result
384
/home/moorepants/miniconda3/lib/python3.5/site-packages/sympy/core/evalf.py
in evalf(self, n, subs, maxn, chop, strict, quad, verbose)
1315 options['quad'] = quad
1316 try:
-> 1317 result = evalf(self, prec + 4, options)
1318 except NotImplementedError:
1319 # Fall back to the ordinary evalf
/home/moorepants/miniconda3/lib/python3.5/site-packages/sympy/core/evalf.py
in evalf(x, prec, options)
1215 if 'subs' in options:
1216 x = x.subs(evalf_subs(prec, options['subs']))
-> 1217 re, im = x._eval_evalf(prec).as_real_imag()
1218 if re.has(re_) or im.has(im_):
1219 raise NotImplementedError
/home/moorepants/miniconda3/lib/python3.5/site-packages/sympy/core/function.py
in _eval_evalf(self, prec)
484
485 with mpmath.workprec(prec):
--> 486 v = func(*args)
487
488 return Expr._from_mpmath(v, prec)
/home/moorepants/miniconda3/lib/python3.5/site-packages/sympy/mpmath/ctx_mp_python.py
in __call__(self, prec, dps, rounding)
344 if not rounding: rounding = rounding2
345 if dps: prec = dps_to_prec(dps)
--> 346 return self.context.make_mpf(self.func(prec, rounding))
347
348 @property
/home/moorepants/miniconda3/lib/python3.5/site-packages/sympy/mpmath/libmp/libelefun.py
in f(prec, rnd)
114 def f(prec, rnd=round_fast):
115 wp = prec + 20
--> 116 v = fixed(wp)
117 if rnd in (round_up, round_ceiling):
118 v += 1
/home/moorepants/miniconda3/lib/python3.5/site-packages/sympy/mpmath/libmp/libelefun.py
in g(prec, **kwargs)
95 memo_prec = f.memo_prec
96 if prec <= memo_prec:
---> 97 return f.memo_val >> (memo_prec-prec)
98 newprec = int(prec*1.05+10)
99 f.memo_val = f(newprec, **kwargs)
TypeError: unsupported operand type(s) for >>: 'int' and 'mpf'
Can someone explain to me what is going on? I would expect "t" to be simply
replaced with the number.
Jason
moorepants.info
+01 530-601-9791
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/CAP7f1Ahs4RpJnziUaR0FUS-K_tGSw-0Bzuwg8cXwvNQvVd0qYQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.