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
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
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))
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
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
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
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
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
def test_with_int(self): with_int = self.valid_data.tolist() with_int[-1] = 2000 valid, _ = validate_classes(with_int) assert valid
def test_list(self): valid, _ = validate_classes(list(self.valid_data)) assert valid
def test_tuple(self): valid, _ = validate_classes(tuple(self.valid_data)) assert valid
def test_sliced(self): valid, _ = validate_classes(self.valid_data[:-1]) assert valid
def test_np_float64(self): valid, _ = validate_classes(self.valid_data.astype(np.float64)) assert valid
def test_quasi_evenly_spaced(self): data = np.round(self.valid_data, 3) valid, _ = validate_classes(data) assert valid
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