[SciPy-user] import scipy mangles types

Pearu Peterson pearu at scipy.org
Thu Apr 22 13:06:31 CDT 2004



On Thu, 22 Apr 2004, John Hunter wrote:

> Here's an interesting bug.
> 
> from Matrix import Matrix
> import scipy
> Matrix([1,2,3])
> 
> produces the traceback
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "/usr/local/lib/python2.3/site-packages/Numeric/Matrix.py", line 69, in __init__
>     if type(data) is types.StringType:
> AttributeError: 'NoneType' object has no attribute 'StringType'
> 
> The types module (used by Matrix) is being replaced by None if scipy
> is imported after Matrix.

Strange, scipy import should not need to touch types at all..

> If I import scipy before I import Matrix, I have no troubles
> 
> import scipy
> from Matrix import Matrix
> Matrix([1,2,3])
> 
> This is a CVS scipy, circa Feb 10 2004.  Haven't checked against 0.3.

That is very old scipy. Anyway, with the recent CVS there are no troubles:

>>> from Matrix import Matrix
>>> import scipy
>>> Matrix([1,2,3])
Matrix([       [1, 2, 3]])

Pearu



More information about the SciPy-user mailing list