def test_with_corret_zero_n(self):
     rst = discrete_features(self.x, 0)
     result = list(rst.reshape(rst.shape[0] * rst.shape[1]))
     exp = np.array([[1, 4, 5, 6, 3, 6, 7, 8, 3, 6, 7, 8, 9, 11],
                     [1, 4, 5, 6, 3, 6, 7, 8, 3, 6, 7, 8, 9, 11],
                     [1, 4, 5, 6, 3, 6, 7, 8, 3, 6, 7, 8, 9, 11]]).T
     expected = list(exp.reshape(exp.shape[0] * exp.shape[1]))
     self.assertSequenceEqual(result, expected)
 def test_with_corret_positive_n(self):
     rst = discrete_features(self.x, 7)
     result = list(rst.reshape(rst.shape[0] * rst.shape[1]))
     exp = np.array([[1, 2, 3, 4, 2, 4, 5, 6, 2, 4, 5, 6, 7, 7],
                     [1, 2, 3, 4, 2, 4, 5, 6, 2, 4, 5, 6, 7, 7],
                     [1, 2, 3, 4, 2, 4, 5, 6, 2, 4, 5, 6, 7, 7]]).T
     expected = list(exp.reshape(exp.shape[0] * exp.shape[1]))
     self.assertSequenceEqual(result, expected)
 def test_default(self):
     rst = discrete_features(self.x)
     result = list(rst.reshape(rst.shape[0] * rst.shape[1]))
     exp = np.array([[1, 2, 2, 3, 1, 3, 4, 5, 1, 3, 4, 5, 5, 5],
                     [1, 2, 2, 3, 1, 3, 4, 5, 1, 3, 4, 5, 5, 5],
                     [1, 2, 2, 3, 1, 3, 4, 5, 1, 3, 4, 5, 5, 5]]).T
     expected = list(exp.reshape(exp.shape[0] * exp.shape[1]))
     self.assertSequenceEqual(result, expected)
 def test_with_invalid_n(self):
     with self.assertRaisesRegex(AttributeError,
                                 r"n must be a positive int") as a:
         discrete_features(self.x, "a")
 def test_with_list_invalid_n(self):
     with self.assertRaisesRegex(
             AttributeError,
             r"N must have the same len with the rows' len") as a:
         discrete_features(self.x, [1, 2])
 def test_with_str_array_positive_n(self):
     rst = discrete_features(self.y, 5)
     result = list(rst.reshape(rst.shape[0] * rst.shape[1]))
     exp = self.y
     expected = list(exp.reshape(exp.shape[0] * exp.shape[1]))
     self.assertSequenceEqual(result, expected)