Reputation: 383
I'm trying to use the following
import numpy as np
from scipy import linalg as LA
from np.LA import matrix_power
from np.LA import multi_dot
But am getting the following error:
File "comp_functions.py", line 9, in <module>
from np.LA import matrix_power
ModuleNotFoundError: No module named 'np'
It's not due to a faulty location as the code in question as I've found to be solution to most other cases on this site as prior to me adding from np.LA import multi_dot
has been working fine for the following function:
def N_eigenvalue(N):
'''
Calculates the eigenvalues and eigenvectors of a matrix (N) using the linalg module in scipy
'''
eigenvalues, eigenvectors = LA.eig(N)
print(eigenvalues)
print(eigenvectors)
return eigenvalues, eigenvectors
Upvotes: 1
Views: 4565
Reputation: 3391
It depends on the version of numpy you are using, in numpy 1.17
it should be imported like this :
from numpy.linalg import matrix_power
from numpy.linalg import multi_dot
Take a look at this link for more information.
Upvotes: 1