問題ない:
>>> 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]])
大問題:
>>> 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]]
うまく機能しますが、配列が大きすぎるため、スパース行列を使用するという私の目的全体を無効にします。いくつかのスパース行列に関連付けられている属性とメソッドをチェックして、高度なインデックスを参照しているものがないか確認しましたが、サイコロはありません。何か案は?