Specter
Specter copied to clipboard
A question about TypeError: 'numpy.float64' object cannot be interpreted as an index
Initially, please forgive my poor English expression ability, I am a beginner of Specter. I meet the question like #13 ,unfortunately I cannot resolve this question by changing my numpy to 1.11.0,so I try to find the origin of the question, I find that when I try to use np.concatenate an int array a and an empty array b,the result array's type is float, as the following code
a = np.array([1, 2, 3, 0, 0])
b = np.array([])
print np.concatenate((a, b))
[1. 2. 3. 0. 0.]
So, when I try to run Specter,when it runs
LibrarySparseMatrix = sparse.coo_matrix((SparseMatrixEntries,(SparseRowIndices,SparseColumnIndices)))
SparseColumnIndices will be a float array and an error will be thrown as " TypeError: 'numpy.float64' object cannot be interpreted as an index" ,in my opinion, because of
SparseColumnIndices = np.concatenate((RefSpectraLibrarySparseColumnIndices,DecoyLibrarySparseColumnIndices))
when DecoyLibrarySparseColumnIndices is empty, SparseColumnIndices will be float
So, I try to modify this sentence to
SparseColumnIndices = np.concatenate((RefSpectraLibrarySparseColumnIndices,DecoyLibrarySparseColumnIndices)).astype(int)
in other words, append ".astype(int)" ,and I want to confirm the feasibility of this scheme, I worry that whether the correctness of the whole code changed?