From b5d07e30321da47d604b99048c1b57c03ec819b0 Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Thu, 31 Oct 2019 13:56:43 +0800 Subject: [PATCH] Add check if scipy is imported in sparse.py (#16574) --- python/mxnet/ndarray/sparse.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/mxnet/ndarray/sparse.py b/python/mxnet/ndarray/sparse.py index 52c5de78ddd4..69c8383df989 100644 --- a/python/mxnet/ndarray/sparse.py +++ b/python/mxnet/ndarray/sparse.py @@ -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 @@ -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()