Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Add check if scipy is imported in sparse.py (#16574)
Browse files Browse the repository at this point in the history
  • Loading branch information
leezu authored and eric-haibin-lin committed Oct 31, 2019
1 parent f9baec9 commit b5d07e3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/mxnet/ndarray/sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,8 @@ def asscipy(self):
indices = self.indices.asnumpy()
indptr = self.indptr.asnumpy()
if not spsp:
raise ImportError("scipy is not available. \
Please check if the scipy python bindings are installed.")
raise ImportError("scipy could not be imported. "
"Please make sure that the scipy is installed.")
return spsp.csr_matrix((data, indices, indptr), shape=self.shape, dtype=self.dtype)

# pylint: disable=abstract-method
Expand Down Expand Up @@ -940,6 +940,9 @@ def csr_matrix(arg1, shape=None, ctx=None, dtype=None):
row = row.asnumpy()
if isinstance(col, NDArray):
col = col.asnumpy()
if not spsp:
raise ImportError("scipy could not be imported. "
"Please make sure that the scipy is installed.")
coo = spsp.coo_matrix((data, (row, col)), shape=shape)
_check_shape(coo.shape, shape)
csr = coo.tocsr()
Expand Down

0 comments on commit b5d07e3

Please sign in to comment.