def test_large_output_iter(self): scml = SCML(max_iter=1, output_iter=2) triplets = np.array([[[0, 1], [2, 1], [0, 0]]]) msg = ("The value of output_iter must be equal or smaller than" " max_iter.") with pytest.raises(ValueError) as raised_error: scml.fit(triplets) assert msg == raised_error.value.args[0]
def test_int_inputs(self, name): value = 1.0 d = {name: value} scml = SCML(**d) triplets = np.array([[[0, 1], [2, 1], [0, 0]]]) msg = ("%s should be an integer, instead it is of type" " %s" % (name, type(value))) with pytest.raises(ValueError) as raised_error: scml.fit(triplets) assert msg == raised_error.value.args[0]
def test_raise_big_number_of_features(): triplets, _, _, X = build_triplets(with_preprocessor=False) triplets = triplets[:3, :, :] estimator = SCML(n_basis=320) set_random_state(estimator) with pytest.raises(ValueError) as exc_info: estimator.fit(triplets) assert exc_info.value.args[0] == \ "Number of features (4) is greater than the number of triplets(3)." \ "\nConsider using dimensionality reduction or using another basis " \ "generation scheme."
def test_dimension_reduction_msg(self): scml = SCML(n_basis=2) triplets = np.array([[[0, 1], [2, 1], [0, 0]], [[2, 1], [0, 1], [2, 0]], [[0, 0], [2, 0], [0, 1]], [[2, 0], [0, 0], [2, 1]]]) msg = ("The number of bases with nonzero weight is less than the " "number of features of the input, in consequence the " "learned transformation reduces the dimension to 1.") with pytest.warns(UserWarning) as raised_warning: scml.fit(triplets) assert msg == raised_warning[0].message.args[0]