我尝试执行以下操作
from scipy import *
from numpy import *
import scipy as s
import numpy as np
import math
import scipy.sparse as l
from plot import Graph3DSolution
import numpy.linalg as lin
currentSol=s.sparse.linalg.inv(I-C)*A*lastSol
我错过了一些代码,但问题是这个
Traceback (most recent call last):
File "explict1wave.py", line 62, in <module>
currentSol=s.sparse.linalg.inv(I-C)*A*lastSol
AttributeError: 'module' object has no attribute 'linalg'
Python 2.7.6 |Anaconda 1.9.1 (x86_64)| (default, Jan 10 2014, 11:23:15)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
im>>> import scipy
>>> scipy.__version__
'0.14.0'
>>>
我查阅文档,看起来这些库自.12以来就存在了。我不知道问题是什么,但我确定它的东西很简单,我没有看到。
答案 0 :(得分:2)
>>> import scipy as s
>>> s.sparse
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'sparse'
>>>
>>> from scipy.sparse import linalg
>>> linalg.inv
<function inv at 0x19b1758>
>>>
一般recommendations for importing functions from scipy。
另一方面,最好避免明星进口。我们不建议使用这些from scipy import *
,from numpy import *
,此处不需要。与import scipy as s
相同。