JanetMatsen / bacteriopop

population dynamics for abundances calculated from meta-omics sequencing
Apache License 2.0
1 stars 3 forks source link

find_fixed_adjacency_matrix not working with full_svd=True #7

Closed JanetMatsen closed 8 years ago

JanetMatsen commented 8 years ago

dmd.find_fixed_adjacency_matrix(0,'order',True)

Numpy error:

`--------------------------------------------------------------------------- LinAlgError Traceback (most recent call last)

in () ----> 1 result = dmd.find_fixed_adjacency_matrix(0,'order',True) /Users/janet/programming/bacteriopop/dynamic_mode_decomposition.py in find_fixed_adjacency_matrix(min_abundance, phylo_column, full_svd) 51 S = np.diag(s) 52 pseu_inv_x = np.dot(np.linalg.inv(V), ---> 53 np.dot(np.linalg.inv(S), np.linalg.pinv(U))) 54 # Adjacency matrix between clusters 55 A = np.dot(Y, pseu_inv_x) /Users/janet/.virtualenvs/seds/lib/python2.7/site-packages/numpy/linalg/linalg.pyc in inv(a) 515 a, wrap = _makearray(a) 516 _assertRankAtLeast2(a) --> 517 _assertNdSquareness(a) 518 t, result_t = _commonType(a) 519 /Users/janet/.virtualenvs/seds/lib/python2.7/site-packages/numpy/linalg/linalg.pyc in _assertNdSquareness(_arrays) 210 for a in arrays: 211 if max(a.shape[-2:]) != min(a.shape[-2:]): --> 212 raise LinAlgError('Last 2 dimensions of the array must be square') 213 214 def _assertFinite(_arrays): LinAlgError: Last 2 dimensions of the array must be square `
Saghar-Hosseini commented 8 years ago

The error was due to a typo in the matrix inverse computation. The function was trying to find the pseudo inverse of a square matrix.