Example #1
0
 def test_empty(self):
     valid, msg = validate_classes([])
     assert isinstance(msg, str)
     print("\n",
           "While passing empty data, the error messages:",
           msg,
           end="\n")
     assert not valid
Example #2
0
 def test_ndim_3(self):
     data = np.linspace(0, 1, 12).reshape((2, 2, -1))
     valid, msg = validate_classes(data)
     print("\n",
           "While passing three-dimensional data, the error messages:",
           msg,
           end="\n")
     assert not valid
Example #3
0
 def test_type_str(self):
     valid, array_or_msg = validate_classes(
         self.valid_data.astype(str).tolist())
     assert valid
     assert isinstance(array_or_msg, np.ndarray)
     assert array_or_msg.ndim == 1
     assert array_or_msg.shape == self.valid_data.shape
     assert np.all(np.less(np.abs(array_or_msg - self.valid_data), 1e-4))
Example #4
0
 def test_not_evenly_spaced(self):
     data = np.linspace(1, 100, 101)
     valid, msg = validate_classes(data)
     print("\n",
           "While it's not evenly spaced, the error messages:",
           msg,
           end="\n")
     assert not valid
Example #5
0
 def test_not_incremental_left(self):
     data = self.valid_data.tolist()
     data[0] = 1e4
     valid, msg = validate_classes(data)
     print("\n",
           "While it's incremental at left end, the error messages:",
           msg,
           end="\n")
     assert not valid
Example #6
0
 def test_not_incremental_middle(self):
     data = self.valid_data.tolist()
     data[5], data[6] = data[6], data[5]
     valid, msg = validate_classes(data)
     print("\n",
           "While it's incremental at middle, the error messages:",
           msg,
           end="\n")
     assert not valid
Example #7
0
 def test_has_nan(self):
     data = self.valid_data.tolist()
     data[0] = np.nan
     data[10] = np.nan
     data[14] = np.nan
     valid, msg = validate_classes(data)
     print("\n",
           "While it has 3 NaN values, the error messages:",
           msg,
           end="\n")
     assert not valid
Example #8
0
 def test_type_none(self):
     valid, msg = validate_classes(None)
     assert isinstance(msg, str)
     print("\n", "While passing `None`, the error messages:", msg, end="\n")
     assert not valid
Example #9
0
 def test_with_int(self):
     with_int = self.valid_data.tolist()
     with_int[-1] = 2000
     valid, _ = validate_classes(with_int)
     assert valid
Example #10
0
 def test_list(self):
     valid, _ = validate_classes(list(self.valid_data))
     assert valid
Example #11
0
 def test_tuple(self):
     valid, _ = validate_classes(tuple(self.valid_data))
     assert valid
Example #12
0
 def test_sliced(self):
     valid, _ = validate_classes(self.valid_data[:-1])
     assert valid
Example #13
0
 def test_np_float64(self):
     valid, _ = validate_classes(self.valid_data.astype(np.float64))
     assert valid
Example #14
0
 def test_quasi_evenly_spaced(self):
     data = np.round(self.valid_data, 3)
     valid, _ = validate_classes(data)
     assert valid
Example #15
0
 def test_valid(self):
     valid, array_or_msg = validate_classes(self.valid_data)
     assert valid
     assert isinstance(array_or_msg, np.ndarray)
     assert array_or_msg.ndim == 1