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

TST Fixes failing test on main #19639

Closed

Conversation

@thomasjpfan thomasjpfan marked this pull request as ready for review March 7, 2021 22:05
@jnothman
Copy link
Member

jnothman commented Mar 8, 2021

This is one of the failing runs? https://github.com/scikit-learn/scikit-learn/runs/2048815281

Copy link
Member

@jnothman jnothman left a 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?

Copy link
Member Author

@thomasjpfan thomasjpfan left a 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

Comment on lines +131 to +135
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)
Copy link
Member Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This avoids possible DeprecationWarning.

Copy link
Member

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"]
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

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():
Copy link
Member Author

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:
Copy link
Member Author

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]):
Copy link
Member Author

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)
Copy link
Member Author

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)
Copy link
Member Author

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]])

@lorentzenchr
Copy link
Member

I get DeprecationWarning: elementwise comparison failed; this will raise an error in the future. in #20250 test_fetch_openml_anneal[False]. It stems from calling np.unique on nan values.

@thomasjpfan
Copy link
Member Author

@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

@jjerphan
Copy link
Member

jjerphan commented Jul 7, 2021

Have the tests targeted by this PR been fixed?

@thomasjpfan
Copy link
Member Author

Closing, since main looks okay now.

@thomasjpfan thomasjpfan closed this Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants