コード例 #1
0
 def test_bw_03(self):
     """Verify that an exception is raised if the row index larger than then number of rows in A."""
     mtrx = csr_matrix([[0, 1, 0],
                        [1, 0, 1],
                        [0, 1, 0]])
     new_row = [-1, -1, -1]
     with self.assertRaises(AssertionError):
         Utils.set_row_csr(mtrx, 3, new_row)
コード例 #2
0
 def test_bw_02(self):
     """Verify that an exception is raised if the new row does not have enough elements."""
     mtrx = csr_matrix([[0, 1, 0],
                        [1, 0, 1],
                        [0, 1, 0]])
     new_row = [-1, -1]
     with self.assertRaises(AssertionError):
         Utils.set_row_csr(mtrx, 2, new_row)
コード例 #3
0
 def test_bw_01(self):
     """Verify that an exception is raised if the new row is not a list."""
     mtrx = csr_matrix([[0, 1, 0],
                        [1, 0, 1],
                        [0, 1, 0]])
     new_row = -1
     with self.assertRaises(AssertionError):
         Utils.set_row_csr(mtrx, 2, new_row)
コード例 #4
0
 def test_gw_04(self):
     mtrx = csr_matrix([[0, 1, 0],
                        [1, 0, 1],
                        [0, 1, 0]])
     new_row = [-1, -1, -1]
     Utils.set_row_csr(mtrx, 2, new_row)
     e = csr_matrix([[0, 1, 0],
                     [1, 0, 1],
                     [-1, -1, -1]])
     TestUtils.equal_csr_matrix(self, mtrx, e, 'new_csr')
コード例 #5
0
 def test_gw_03(self):
     mtrx = csr_matrix([[0, 1, 0],
                        [1, 0, 1],
                        [0, 1, 0]])
     new_row = np.array([-1, -1, -1], dtype=float)
     Utils.set_row_csr(mtrx, 2, new_row)
     e = csr_matrix([[0, 1, 0],
                     [1, 0, 1],
                     [-1, -1, -1]])
     TestUtils.equal_csr_matrix(self, mtrx, e, 'new_csr')
コード例 #6
0
 def test_gw_01(self):
     mtrx = csr_matrix([[0, 1, 0],
                        [1, 0, 1],
                        [0, 1, 0]])
     new_row = np.array([2, 3, 4])
     Utils.set_row_csr(mtrx, 0, new_row)
     e = csr_matrix([[2, 3, 4],
                     [1, 0, 1],
                     [0, 1, 0]])
     TestUtils.equal_csr_matrix(self, mtrx, e, 'new_csr')