-
-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
TST Fixes failing test on main #19639
Conversation
This is one of the failing runs? https://github.com/scikit-learn/scikit-learn/runs/2048815281 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are some unrelated changes in here, aren't there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jnothman I left comments connecting each diff and the corresponding test that it fixes
feature = data_by_id.data[:, feature_idx] | ||
if np.all(np.isnan(feature)): | ||
# no need to check when all values are nan | ||
continue | ||
values = np.unique(feature) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To resolve test_fetch_openml_anneal
and other test in test_openml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This avoids possible DeprecationWarning
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now fixed in #20327, right?
@@ -33,10 +33,10 @@ | |||
|
|||
# Toy sample | |||
X = [[-2, -1], [-1, -1], [-1, -2], [1, 1], [1, 2], [2, 1]] | |||
y_class = ["foo", "foo", "foo", 1, 1, 1] # test string class labels | |||
y_class = ["foo", "foo", "foo", "bar", "bar", "bar"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To resolve test_classification_toy
. Numpy now warns when running np.array(["foo", 1])
.
@@ -70,13 +70,37 @@ cdef class LossFunction: | |||
"""Python version of `dloss` for testing. | |||
|
|||
Pytest needs a python function and can't use cdef functions. | |||
|
|||
Parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To resolve test_docstring_parameters
@@ -1620,11 +1620,12 @@ cdef class BinaryTree: | |||
- 'linear' | |||
- 'cosine' | |||
Default is kernel = 'gaussian' | |||
atol, rtol : float, default=0, 1e-8 | |||
atol : float, default=0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To resolve test_docstring_parameters
. Building with the newest version of Cython now exposes these docstrings correctly.
@@ -475,7 +475,18 @@ def fit(self, X, y): | |||
raise TypeError("The outlier_label of classes {} is " | |||
"supposed to be a scalar, got " | |||
"{}.".format(classes, label)) | |||
if np.append(classes, label).dtype != classes.dtype: | |||
# Starting in numpy 1.21 np.append admits a warning when |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To resolve test_radius_neighbors_classifier_outlier_labeling
force_all_finite=force_all_finite) | ||
|
||
# starting in numpy 1.21 mixed typed `X` will raise a FutureWarning | ||
with warnings.catch_warnings(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To resolve test_one_hot_encoder_warning
@@ -63,7 +63,11 @@ def compute_class_weight(class_weight, *, classes, y): | |||
raise ValueError("class_weight must be dict, 'balanced', or None," | |||
" got: %r" % class_weight) | |||
for c in class_weight: | |||
i = np.searchsorted(classes, c) | |||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To resolve test_compute_class_weight_not_present
@@ -48,10 +49,19 @@ def test_encode_with_check_unknown(): | |||
|
|||
def _assert_check_unknown(values, uniques, expected_diff, expected_mask): | |||
diff = _check_unknown(values, uniques) | |||
assert_array_equal(diff, expected_diff) | |||
if is_scalar_nan(expected_diff[-1]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To resolve test_check_unknown_missing_values
failing
@@ -303,7 +310,15 @@ def type_of_target(y): | |||
_assert_all_finite(y) | |||
return 'continuous' + suffix | |||
|
|||
if (len(np.unique(y)) > 2) or (y.ndim >= 2 and len(y[0]) > 1): | |||
try: | |||
unique_values = np.unique(y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolves test_unique_labels_mixed_types
@@ -160,7 +160,14 @@ def is_multilabel(y): | |||
(y.dtype.kind in 'biu' or # bool, int, uint | |||
_is_integral_float(np.unique(y.data)))) | |||
else: | |||
labels = np.unique(y) | |||
try: | |||
labels = np.unique(y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolves test_unique_labels_mixed_types
:
with pytest.raises(ValueError):
unique_labels([["1", 2], [1, 3]])
I get |
@lorentzenchr For now, we are ignoring that issue here: #20327 since it is a bug in numpy which has a fix here: numpy/numpy#19301 |
Have the tests targeted by this PR been fixed? |
Closing, since |
Fixes failing tests on main.
Here are the failing runs: https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=27158&view=logs&jobId=dfe99b15-50db-5d7b-b1e9-4105c42527cf&j=dfe99b15-50db-5d7b-b1e9-4105c42527cf&t=ef785ae2-496b-5b02-9f0e-07a6c3ab3081