Check format of sparse matrix in numpy_cupy_array_equal
@@ -299,14 +299,12 @@ def _convert_output_to_ndarray(c_out, n_out, sp_name):
Returns:
The tuple of cupy.ndarray and numpy.ndarray.
"""
- if sp_name is not None:
- import scipy.sparse
- if cupyx.scipy.sparse.issparse(c_out):
+ if sp_name is not None and cupyx.scipy.sparse.issparse(c_out):
# Sparse output case.
- if scipy.sparse.issparse(n_out):
+ import scipy.sparse
+ assert scipy.sparse.issparse(n_out)
+ assert c_out.format == n_out.format
return c_out.A, n_out.A
- if isinstance(n_out, numpy.generic):
- return c_out.A, n_out
if (isinstance(c_out, cupy.ndarray)
and isinstance(n_out, (numpy.ndarray, numpy.generic))):
# ndarray output case.
