From: Scott S. <sin...@uk...> - 2006-10-12 07:12:34
|
Fernando Perez wrote: > Please note that I see a valid reason for scipy.foo != numpy.foo when > the scipy version uses code with extra features, is faster, has > additional options, etc. But as I said in a previous message, I think > that /for the same input/, we should really try to satisfy that > > numpy.foo(x) == scipy.foo(x) (which is NOT the same as 'numpy.foo is scipy.foo') > > within reason. As far as I can tell this is exactly what happens. Consider the issue under discussion... ---------------------------------- >>> import numpy as np >>> np.sqrt(-1) -1.#IND >>> np.sqrt(-1+0j) 1j >>> a = complex(-1) >>> np.sqrt(a) 1j >>> import scipy as sp >>> sp.sqrt(-1) -1.#IND >>> np.sqrt(-1+0j) 1j >>> sp.sqrt(a) 1j >>> np.__version__ '1.0rc1' >>> sp.__version__ '0.5.1' >>> ---------------------------------- I'm sure that this hasn't changed in the development versions. Surely the point is that when your algorithm can potentially produce a complex result, the logical thing to do is to use a complex data type. In this case Numpy and Scipy behave in a way which is intuitive. If complex results are surprising and unexpected then the algorithm is probably in error or poorly understood ;-) Cheers, Scott |