How to make sqrt(-1) be 1j
Bill Baxter
wbaxter at gmail.com
Fri Oct 13 00:38:48 CDT 2006
On 10/13/06, Tim Hochberg <tim.hochberg at ieee.org> wrote:
> For this sort of thing, I
> would just make a new module to pull together the function I want and
> use that instead. It's then easy to explain that this new module bbeconf
> (Bill Baxter's Excellent Collection Of Numeric Functions) is actually an
> amalgamation of stuff from multiple sources.
>
> # bbeconf.py
> from numpy import *
> fromnumpy.scimath import sqrt
> # possibly some other stuff to correctly handle subpackages...
That does sound like a good way to do it.
Then you just tell your users to import 'eduNumpy' rather than numpy,
and you're good to go.
Added that suggestion to http://www.scipy.org/NegativeSquareRoot
I'd like to ask one basic Python question related my previous
suggestion of doing things like "numpy.sqrt = numpy.lib.scimath.sqrt":
In python does that make it so that any module importing numpy in the
same program will now see the altered sqrt function? E.g. in my
program I do "import A,B". Module A alters numpy.sqrt. Does that
also modify how module B sees numpy.sqrt?
If so then that's a very good reason not to do it that way.
I've heard people using the term "monkey-patch" before. Is that what that is?
--bb
-------------------------------------------------------------------------
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
More information about the Numpy-discussion
mailing list