Hi all,

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.

e.g:

>> numpy.cos(sympy.pi)

<type 'exceptions.AttributeError'>: cos

whereas:

>> math.cos(sympy.pi)

-1.0

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

solutions?

Thanks in advance,

Sebastian

_______________________________________________

Numpy-discussion mailing list

[hidden email]
http://projects.scipy.org/mailman/listinfo/numpy-discussion