In the ongoing fwrapification of SciPy [1], I'm getting regression test
breakage because of this:
def func(float x):
return x
>>> func(1 + 0j)
Traceback (most recent call last):
...
TypeError: can't convert complex to float
I'm wondering: Would people be OK to Cython so that when the imaginary
part is *exactly* 0, it is OK to convert to native float? Or is failing
hard the preferred behaviour?
(For all I know, SciPy may prefer to change their behaviour; so I'm just
doing a poll for now.)
I guess the way to do it would be to try float conversion first, and if
that fails, try complex conversion and see if the imaginary part ends up
as 0. That is, it would mean that __complex__ would be called on passed
in objects that do not support __float__ in the example above.
Dag Sverre
[1]
http://fortrancython.wordpress.com/2010/11/03/fwrap-to-be-used-by-scipy/
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev