Exemplo n.º 1
0
 def test_empty(self):
     valid, msg = validate_distributions([[]])
     assert isinstance(msg, str)
     print("\n",
           "While passing empty data, the error messages:",
           msg,
           end="\n")
     assert not valid
Exemplo n.º 2
0
 def test_ndim_3(self):
     data = np.linspace(0, 1, 12).reshape((2, 2, -1))
     valid, msg = validate_distributions(data)
     print("\n",
           "While passing three-dimensional data, the error messages:",
           msg,
           end="\n")
     assert not valid
Exemplo n.º 3
0
 def test_type_str(self):
     valid, array_or_msg = validate_distributions(
         self.valid_data.astype(str).tolist())
     assert valid
     assert isinstance(array_or_msg, np.ndarray)
     assert array_or_msg.ndim == 2
     assert array_or_msg.shape == self.valid_data.shape
     assert np.all(np.less(np.abs(array_or_msg - self.valid_data), 1e-4))
Exemplo n.º 4
0
 def test_has_nan(self):
     data = self.valid_data.copy()
     data[:3, -5:] = np.nan
     valid, msg = validate_distributions(data)
     print("\n",
           "While it has NaN values, the error messages:",
           msg,
           end="\n")
     assert not valid
Exemplo n.º 5
0
 def test_not_sum_to_one(self):
     data = self.valid_data.copy()
     data[:3, -5:] = 1e3
     valid, msg = validate_distributions(data)
     print(
         "\n",
         "While the sums of some rows are not equal to 1, the error messages:",
         msg,
         end="\n")
     assert not valid
Exemplo n.º 6
0
 def test_type_none(self):
     valid, msg = validate_distributions(None)
     assert isinstance(msg, str)
     print("\n", "While passing `None`, the error messages:", msg, end="\n")
     assert not valid
Exemplo n.º 7
0
 def test_with_int(self):
     with_int = self.valid_data.tolist()
     with_int[0][1] += with_int[0][0]
     with_int[0][0] = 0
     valid, _ = validate_distributions(with_int)
     assert valid
Exemplo n.º 8
0
 def test_list(self):
     valid, _ = validate_distributions(self.valid_data.tolist())
     assert valid
Exemplo n.º 9
0
 def test_sliced(self):
     valid, _ = validate_distributions(self.valid_data[:-1])
     assert valid
Exemplo n.º 10
0
 def test_np_float64(self):
     valid, _ = validate_distributions(self.valid_data.astype(np.float64))
     assert valid
Exemplo n.º 11
0
 def test_valid(self):
     valid, array_or_msg = validate_distributions(self.valid_data.tolist())
     assert valid
     assert isinstance(array_or_msg, np.ndarray)
     assert array_or_msg.ndim == 2
     assert np.all(np.less(np.sum(array_or_msg, axis=1) - 1.0, 1e-4))