Stefan van der Walt wrote: >I agree with Fernando on this one. > >Further, if I understand correctly, changing sqrt and power to give >the right answer by default will slow things down somewhat. But is it >worth sacrificing intuitive usage for speed? > > For NumPy, yes.
This is one reason that NumPy by itself is not a MATLAB replacement. >N.power(2,-2) == 0 > >and > >N.sqrt(-1) == nan > >just doesn't feel right. > Only because your expectations are that NumPy *be* a MATLAB replacement. The problem is that it sacrifices too much for that to be the case. And we all realize that NumPy needs more stuff added to it to be like IDL/MATLAB such as SciPy, Matplotlib, IPython, etc. >Why not then have > >N.power(2,-2) == 0.24 >N.sqrt(-1) == 1j > >and write a special function that does fast calculation of >square-roots for positive values? > > We've already done this. The special functions are called numpy.power numpy.sqrt (notice that if you do numpy.sqrt(-1+0j) you get the "expected" answer emphasizing that numpy does no "argument" checking to determine the output). The "intuitive" functions (which must do argument checking) are (in numpy.lib.scimath) but exported as scipy.power (actually I need to check that one...) scipy.sqrt What could be simpler? ;-) -Travis ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion