No problem:
>>> t = np.array([[1,1,1,1,1],[2,2,2,2,2],[3,3,3,3,3],[4,4,4,4,4],[5,5,5,5,5]])
>>> x = np.arange(5).reshape((-1,1)); y = np.arange(5)
>>> print (t[[x]],t[[y]])
Big problem:
>>> s = scipy.sparse.csr_matrix(t)
>>> print (s[[x]].toarray(),s[[y]].toarray())
Traceback (most recent call last):
File "<pyshell#22>", line 1, in <module>
: :
: :
ValueError: data, indices, and indptr should be rank 1
s.toarray()[[x]]
works great, but defeats the whole purpose of me using sparse matrices as my arrays are too big. I've checked the Attributes and Methods associated with some of the sparse matrices for anything referencing Advanced Indexing, but no dice. Any ideas?
t[np.array([x])]
instead oft[x,]
adding an extra dimension to the individual index. And I would not trust the sparse indexing to handle this case necessarily as you want it to. – seberg