ok, I don’t think I can explain this problem with words, here is an ipython session fragment where I import scipy to build a sparse matrix.
In [1]: import scipy as sp
In [2]: a = sp.sparse.lil_matrix((5,5))
AttributeError Traceback (most recent call last)
/home/liveuser/<ipython-input-2-b5a55fc2d0ac> in <module>()
AttributeError: 'module' object has no attribute 'sparse'
In [3]: import scipy.sparse as spar
In [4]: ax = spar.lil_matrix((5,5))
In [5]: a = sp.sparse.lil_matrix((5,5))
In [6]: a
Out[6]:
<5x5 sparse matrix of type '<type 'numpy.float64'>'
with 0 stored elements in LInked List format>
In [7]: ax
Out[7]:
<5x5 sparse matrix of type '<type 'numpy.float64'>'
with 0 stored elements in LInked List format>
what happens there, why it is impossible to create a sparse matrix using sp, the first time I import a sparse submodule in a certain way (as in a fragment), now both sp and spar variables can be used to build sparse matrices. (I think they are just references to the same object)
I reproduced this python default shell (so it is not ipython specific)
what happens is it by design ?? if so kindly detailed. or is it a mistake?
My system is Fedora 16 KDE-scientific, 64-bit.
source
share