Пример #1
0
 def test_gw_03(self):
     line = 'before_20141017'
     character = '_'
     r = Utils.substring_after_character(line, character,
                                         include_character=False)
     e = '20141017'
     TestUtils.equal_str(self, r, e, 'line')
Пример #2
0
 def test_gw_02(self):
     mtrx = csr_matrix(np.identity(6), dtype=int)
     r = Utils.delete_rows_csr(mtrx, [0, 1, 2])
     e = csr_matrix([[0, 0, 0, 1, 0, 0],
                     [0, 0, 0, 0, 1, 0],
                     [0, 0, 0, 0, 0, 1]])
     TestUtils.equal_csr_matrix(self, r, e, 'removed row csr_matrix')
Пример #3
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')
Пример #4
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')
Пример #5
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')
Пример #6
0
 def test_gw_01(self):
     mtrx = csr_matrix(np.identity(6), dtype=int)
     r = Utils.delete_rows_csr(mtrx, [1, 3])
     e = csr_matrix([[1, 0, 0, 0, 0, 0],
                     [0, 0, 1, 0, 0, 0],
                     [0, 0, 0, 0, 1, 0],
                     [0, 0, 0, 0, 0, 1]])
     TestUtils.equal_csr_matrix(self, r, e, 'removed row csr_matrix')
     orig = csr_matrix(np.identity(6), dtype=int)
     TestUtils.equal_csr_matrix(self, mtrx, orig, 'original csr_matrix')
Пример #7
0
 def disabled_test_gw_04(self):
     """
     Note: the function does not work for nested sublists,
     so this test will fail. That's why it is commented out.
     It does not make sense to check for failure, since it
     would be better if it did not fail. It's a fact of life.
     """
     a = np.array([[1], [2, [3, 4]], [], [2, 3, 4]])
     r = Utils.flatten_np_array(a)
     e = np.array([1, 2, 3, 4, 2, 3, 4])
     TestUtils.equal_np_matrix(self, r, e, 'flat array')
Пример #8
0
 def gw(self, hsb, e):
     """Verify that a hsb value is properly transformed into a rgb value"""
     r = Utils.hsb2rgb(hsb)
     TestUtils.equal_list(self, r, e)
Пример #9
0
 def test_gw_03(self):
     mtrx = csr_matrix(np.identity(6), dtype=int)
     r = Utils.delete_rows_csr(mtrx, range(6))
     e = (0, 6)
     TestUtils.equal_tuple_numbers(self, r.shape, e, 'shape of empty matrix')
Пример #10
0
 def gw(self, a, e):
     """Verify that None rows are filtered out a frequency count."""
     r = Utils.filter_none_from_frequency_count(a)
     TestUtils.equal_list(self, r, e)
Пример #11
0
 def gw(self, a, e):
     """Verify that a frequency count can be converted into an occurrence list."""
     r = Utils.frequency_count2occurrence_list(a)
     TestUtils.equal_list(self, r, e)
Пример #12
0
 def gw(self, lst, dx, e):
     """Verify that the smallest element is incremented."""
     Utils.increment_smallest(lst, dx)
     TestUtils.equal_list(self, lst, e)
Пример #13
0
 def gw(self, a, e):
     r = Utils.flatten_np_array(a)
     TestUtils.equal_list(self, r, e)
Пример #14
0
 def gw(self, a, e):
     r = Utils.filter_array(a)
     TestUtils.equal_list(self, r, e)