Ejemplo n.º 1
0
def test_check_input_invalid_tuples_with_preprocessor(wrong_labels):
  n_samples, n_features, n_pairs = 10, 4, 5
  rng = np.random.RandomState(42)
  pairs = rng.randint(10, size=(n_pairs, 2))
  preprocessor = rng.randn(n_samples, n_features)
  expected_msg = ("When training on pairs, the labels (y) should contain "
                  "only values in [-1, 1]. Found an incorrect value.")
  with pytest.raises(ValueError) as raised_error:
    check_input(pairs, wrong_labels, preprocessor=ArrayIndexer(preprocessor),
                type_of_inputs='tuples')
  assert str(raised_error.value) == expected_msg
Ejemplo n.º 2
0
def test_preprocessor_error_message():
    """Tests whether the preprocessor returns a preprocessor error when there
  is a problem using the preprocessor
  """
    preprocessor = ArrayIndexer(np.array([[1.2, 3.3], [3.1, 3.2]]))

    # with tuples
    X = np.array([[[2, 3], [3, 3]], [[2, 3], [3, 2]]])
    # There are less samples than the max index we want to preprocess
    with pytest.raises(PreprocessorError):
        preprocess_tuples(X, preprocessor)

    # with points
    X = np.array([[1], [2], [3], [3]])
    with pytest.raises(PreprocessorError):
        preprocess_points(X, preprocessor)