diff --git a/sliceline/slicefinder.py b/sliceline/slicefinder.py index 31facff..c6cfa38 100644 --- a/sliceline/slicefinder.py +++ b/sliceline/slicefinder.py @@ -140,7 +140,7 @@ def fit(self, X, errors): self._check_params() # Check that X and e have correct shape - X_array, errors = check_X_e(X, errors) + X_array, errors = check_X_e(X, errors, y_numeric=True) self._check_feature_names(X, reset=True) diff --git a/sliceline/validation.py b/sliceline/validation.py index a1acb75..1d50add 100644 --- a/sliceline/validation.py +++ b/sliceline/validation.py @@ -805,8 +805,8 @@ def _check_y(y, multi_output=False, y_numeric=False, estimator=None): y = column_or_1d(y, warn=True) _assert_all_finite(y, input_name="y", estimator_name=estimator_name) _ensure_no_complex_data(y) - if y_numeric and y.dtype.kind == "O": - y = y.astype(np.float64) + if y_numeric and y.dtype.kind in ("O", "b"): + y = y.astype(np.float32) return y diff --git a/tests/conftest.py b/tests/conftest.py index 4cefdb0..9b828c3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -111,7 +111,7 @@ def basic_test_data(): @pytest.fixture def experiments(): """Implement several end-to-end examples with the expected outputs regarding the inputs.""" - # Experiment 1: basic case + # Experiment 1: basic case with boolean errors np.random.seed(1) n_small = 10 X_1 = np.array( @@ -121,7 +121,7 @@ def experiments(): np.random.randint(1, 4, size=2 * n_small), ] ).T - errors_1 = np.array([1] * n_small + [0] * n_small) + errors_1 = np.array([True] * n_small + [False] * n_small) expected_top_slices_1 = np.array([[1, 1, None], [None, 1, 2], [1, None, 2]]) experiment_1 = Experiment(X_1, errors_1, expected_top_slices_1) @@ -139,7 +139,7 @@ def experiments(): ).T errors_2 = np.array([1] * n_small + [0] * n_small) expected_top_slices_2 = np.array( - [[None, 1.0, None, None, 1.0, None], [None, None, 4.0, None, 1.0, None]] + [[None, 1, None, None, 1, None], [None, None, 4, None, 1, None]] ) experiment_2 = Experiment(X_2, errors_2, expected_top_slices_2)