__float__ is not called when instance can not evaluated.
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