[Numpy-discussion] __float__ is not called when instance can not evaluated.
Tue May 6 14:03:14 CDT 2008
I'm currently working on a function that converts a
sympy (http://code.google.com/p/sympy) expression to a lambda-function.
In this lambda-function all sympy builtin functions are replaced by
numpy functions, since they are faster.
Now it may happen that users pass sympy-symbols like pi to these lambda
functions and so it is possible that numpy-functions get these symbols.
The same functionality is implemented using python's math module, and it
works because the math functions call the __float__ method and therefor
get a number they can work with.
However, numpy doesn't do this, it only looks if there is a method with
the same name as the called function.
<type 'exceptions.AttributeError'>: cos
Would it be possible to change numpys behaviour so that x.__float__() is
tried after x.cos() has failed? Or are there any other possible
Thanks in advance,
More information about the Numpy-discussion