Test initializing `dia_matrix` from SciPy
@@ -138,6 +138,18 @@ class TestDiaMatrixInit(unittest.TestCase):
sp.dia_matrix(
(self.data(xp), self.offsets(xp)), shape=None)
+ def test_scipy_sparse(self):
+ s_h = scipy.sparse.dia_matrix((self.data(numpy), self.offsets(numpy)),
+ shape=self.shape)
+ s_d = sparse.dia_matrix(s_h)
+ s_h2 = s_d.get()
+ assert s_h.shape == s_d.shape
+ assert s_h.dtype == s_d.dtype
+ assert s_h.shape == s_h2.shape
+ assert s_h.dtype == s_h2.dtype
+ assert (s_h.data == s_h2.data).all()
+ assert (s_h.offsets == s_h2.offsets).all()
+
@testing.numpy_cupy_allclose(sp_name='sp', atol=1e-5)
def test_intlike_shape(self, xp, sp):
s = sp.dia_matrix((self.data(xp), self.offsets(xp)),
