ZiyueHuang commented on issue #8259: [WIP] check_format of ndrray, mainly for csr URL: https://github.com/apache/incubator-mxnet/pull/8259#issuecomment-336613288 Seems that scipy will not check the validity for computations like `sqrt` or `transpose`, but will check for methods like `toarray`. scipy has `scipy.sparse.csr_matrix.check_format`. ```python >>> import scipy.sparse as spsp >>> a = spsp.csr_matrix(([0],[10],[0,1]), shape=(1,2)) >>> a.sqrt() <1x2 sparse matrix of type '<type 'numpy.float64'>' with 1 stored elements in Compressed Sparse Row format> >>> a.toarray() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/dist-packages/scipy/sparse/compressed.py", line 940, in toarray return self.tocoo(copy=False).toarray(order=order, out=out) File "/usr/lib/python2.7/dist-packages/scipy/sparse/compressed.py", line 936, in tocoo return coo_matrix((data,(row,col)), self.shape) File "/usr/lib/python2.7/dist-packages/scipy/sparse/coo.py", line 182, in __init__ self._check() File "/usr/lib/python2.7/dist-packages/scipy/sparse/coo.py", line 238, in _check raise ValueError('column index exceeds matrix dimensions') ValueError: column index exceeds matrix dimensions >>> a.check_format() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/dist-packages/scipy/sparse/compressed.py", line 177, in check_format (minor_name,minor_dim)) ValueError: column index values must be < 2 >>> a.transpose() <2x1 sparse matrix of type '<type 'numpy.int64'>' with 1 stored elements in Compressed Sparse Column format> ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
With regards, Apache Git Services