Skip to content

Commit

Permalink
Update validation to handle boolean errors (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
adedaran authored Mar 24, 2023
1 parent fa486d7 commit dbf60a3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion sliceline/slicefinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def fit(self, X, errors):
self.min_sup = int(self.min_sup * len(X))

# 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

0 comments on commit dbf60a3

Please sign in to comment.