Beispiel #1
0
    def test_to_dense_with_zero(self):
        mat = SparseMatrix.zero((5, 5), dtype=np.uint16)

        expected = np.zeros((5, 5), dtype=np.uint16)
        result = mat.to_dense()

        self.assertTrue(np.array_equal(result, expected))
Beispiel #2
0
 def test_from_list_with_no_unique_elements(self):
     mat = SparseMatrix.from_list([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0],
                                   [0, 0, 0, 0]])
     self.assertEqual(len(mat), 0)
     self.assertEqual(mat, SparseMatrix.zero((4, 4)))
     self.assertTrue(np.array_equal(mat.cols, np.array([])))
     self.assertTrue(np.array_equal(mat.data, np.array([])))
     self.assertTrue(np.array_equal(mat.rows, np.array([])))