The simplest example:
f = piecewise([[[-pi-1, -pi/2], 0], [(-pi/2,pi/2), 1], [[pi/2, pi+1], 0]])
print(f(-pi))
which gives the traceback:
TypeError Traceback (most recent call last)
<ipython-input-49-655f6ae30ee7> in <module>()
----> 1 f(-pi)
/Applications/SageMath-8.7.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/symbolic/expression.pyx
in sage.symbolic.expression._eval_on_operands.new_f
(build/cythonized/sage/symbolic/expression.cpp:66491)()
12677 new_args = list(ex._unpack_operands())
12678 new_args.extend(args)
> 12679 return f(ex, *new_args, **kwds)
12680 return new_f
12681
/Applications/SageMath-8.7.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/functions/piecewise.py
in __call__(self, parameters, variable, value, **kwds)
472 if value is not None:
473 substitution[variable] = value
--> 474 return self.subs(substitution)
475
476 def _fast_float_(self, *args):
/Applications/SageMath-8.7.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/symbolic/expression.pyx
in sage.symbolic.expression.Expression.substitute
(build/cythonized/sage/symbolic/expression.cpp:30025)()
5289 smap.insert(make_pair((<Expression>self.coerce_in(k))._gobj,
5290
(<Expression>self.coerce_in(v))._gobj))
-> 5291 res = self._gobj.subs_map(smap, 0)
5292 return new_Expression_from_GEx(self._parent, res)
5293
/Applications/SageMath-8.7.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/functions/piecewise.py
in _subs_(self, subs_map, options, parameters, x)
226 if hasattr(point, 'pyobject'):
227 # unwrap any numeric values
--> 228 point = point.pyobject()
229 else:
230 raise ValueError('substituting the piecewise variable must
result in real number')
/Applications/SageMath-8.7.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/symbolic/expression.pyx
in sage.symbolic.expression.Expression.pyobject
(build/cythonized/sage/symbolic/expression.cpp:6083)()
372
373 cdef class Expression(CommutativeRingElement):
--> 374 cpdef object pyobject(self):
375 """
376 Get the underlying Python object.
/Applications/SageMath-8.7.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/symbolic/expression.pyx
in sage.symbolic.expression.Expression.pyobject
(build/cythonized/sage/symbolic/expression.cpp:6009)()
428
429 if not is_a_numeric(self._gobj):
--> 430 raise TypeError("self must be a numeric expression")
431 return py_object_from_numeric(self._gobj)
432
TypeError: self must be a numeric expression
sage: f(-pi)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-50-655f6ae30ee7> in <module>()
----> 1 f(-pi)
/Applications/SageMath-8.7.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/symbolic/expression.pyx
in sage.symbolic.expression._eval_on_operands.new_f
(build/cythonized/sage/symbolic/expression.cpp:66491)()
12677 new_args = list(ex._unpack_operands())
12678 new_args.extend(args)
> 12679 return f(ex, *new_args, **kwds)
12680 return new_f
12681
/Applications/SageMath-8.7.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/functions/piecewise.py
in __call__(self, parameters, variable, value, **kwds)
472 if value is not None:
473 substitution[variable] = value
--> 474 return self.subs(substitution)
475
476 def _fast_float_(self, *args):
/Applications/SageMath-8.7.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/symbolic/expression.pyx
in sage.symbolic.expression.Expression.substitute
(build/cythonized/sage/symbolic/expression.cpp:30025)()
5289 smap.insert(make_pair((<Expression>self.coerce_in(k))._gobj,
5290
(<Expression>self.coerce_in(v))._gobj))
-> 5291 res = self._gobj.subs_map(smap, 0)
5292 return new_Expression_from_GEx(self._parent, res)
5293
/Applications/SageMath-8.7.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/functions/piecewise.py
in _subs_(self, subs_map, options, parameters, x)
226 if hasattr(point, 'pyobject'):
227 # unwrap any numeric values
--> 228 point = point.pyobject()
229 else:
230 raise ValueError('substituting the piecewise variable must
result in real number')
/Applications/SageMath-8.7.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/symbolic/expression.pyx
in sage.symbolic.expression.Expression.pyobject
(build/cythonized/sage/symbolic/expression.cpp:6083)()
372
373 cdef class Expression(CommutativeRingElement):
--> 374 cpdef object pyobject(self):
375 """
376 Get the underlying Python object.
/Applications/SageMath-8.7.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/symbolic/expression.pyx
in sage.symbolic.expression.Expression.pyobject
(build/cythonized/sage/symbolic/expression.cpp:6009)()
428
429 if not is_a_numeric(self._gobj):
--> 430 raise TypeError("self must be a numeric expression")
431 return py_object_from_numeric(self._gobj)
432
TypeError: self must be a numeric expression
--
You received this message because you are subscribed to the Google Groups
"sage-support" 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/sage-support.
For more options, visit https://groups.google.com/d/optout.