On Tuesday, November 15, 2016 at 4:36:01 AM UTC+1, Nils Bruin wrote: > > ... The "abs" in the global namespace is just the generic python one: > abs(a) dispatches to a.__abs__() > > sage: class A(object): > ....: def __abs__(self): > ....: return "abs" > ....: > sage: a=A() > sage: abs(a) > 'abs' > sage: sage.functions.all.abs_symbolic(a) > TypeError: cannot coerce arguments: no canonical coercion from <class > '__main__.A'> to Symbolic Ring >
However, using the #21657 branch where abs is imported from functions.other I get sage: abs(a) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-3-6ae1d92eec8c> in <module>() ----> 1 abs(a) /home/ralf/sage/src/sage/symbolic/function.pyx in sage.symbolic.function. BuiltinFunction.__call__ (build/cythonized/sage/symbolic/function.cpp:11333 )() 993 res = self._evalf_try_(*args) 994 if res is None: --> 995 res = super(BuiltinFunction, self).__call__( 996 *args, coerce=coerce, hold=hold) 997 /home/ralf/sage/src/sage/symbolic/function.pyx in sage.symbolic.function. Function.__call__ (build/cythonized/sage/symbolic/function.cpp:6218)() 471 if callable(method): 472 return method() --> 473 raise TypeError("cannot coerce arguments: %s" % (err )) 474 475 else: # coerce == False TypeError: cannot coerce arguments: no canonical coercion from <class '__main__.A'> to Symbolic Ring so it seems the Python abs can be overridden. -- 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 sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.