Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update validation to handle boolean errors #30

Merged
merged 2 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sliceline/slicefinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions sliceline/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)

Expand All @@ -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)

Expand Down