[SciPy-user] Right way to import scipy

Andrew Straw strawman at astraw.com
Mon Feb 20 23:06:16 CST 2006


Robert Kern wrote:

>Bill Baxter wrote:
>  
>
>>I posted this on the numpy list, but it seems more a scipy issue.
>>
>>If you do this:
>>
>>import numpy as N
>>import scipy as S
>>
>>Then S.linalg looks to be identical to N.linalg.  In particular it
>>doesn't have things like lu, qr, gmres, etc.
>>
>>If you subsequently do 'from scipy.linalg import lu', then suddenly
>>S.linalg looks different from N.linalg, and it has not just lu, but all
>>the other scipy linalg goodies too.
>>
>>Is this a bug?  I would like to add info about getting at these
>>functions to the Scipy for Matlab Users wiki page, but I'd like to know
>>first if
>>A) this is the expected behavior, or just a bug and
>>    
>>
>
>It's expected if you know what's going on, but not really desirable.
>scipy/__init__.py does a "from numpy import *" which is pulling in the linalg
>package. I'm pretty sure we don't want that. In fact, we already have a "del
>lib" statement to clear that conflicting module, so we should just add a "del
>linalg" statement, too.
>  
>
+1

I was bitten by this one today... Just as a point of reference to
explain how: I was looking for the fastest SVD code and figured if it
what was in scipy was different than numpy, I'd use the scipy version
which would presumably be using optimizations that couldn't be in numpy.
A quick numpy.linalg.svd == scipy.linalg.svd led me to believe scipy had
nothing on numpy and simply used the numpy version.  Perhaps I'm right
about the equivalence of scipy and numpy's SVD functions (and perhaps
I'm wrong), but it's clear to me now that my "test" didn't test anything
and thus I'll have to test again.



More information about the SciPy-user mailing list