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

FIX ignore spurious RuntimeWarning in test on macOS M1 machines #21070

Closed

Conversation

ogrisel
Copy link
Member

@ogrisel ogrisel commented Sep 16, 2021

The code in this test can raise:

RuntimeWarning: divide by zero encountered in reciprocal

but this warning should not be raised. See the upstream report: numpy/numpy#18555

In the mean time, let's ignore those warnings in this test to make it pass and avoid crashing the scikit-learn tests on those systems.

The code in this test can raise:

  RuntimeWarning: divide by zero encountered in reciprocal

but this warning should not be raised. See the upstream report:
numpy/numpy#18555

In the mean time, let's ignore those warnings in this test to
make it pass and avoid crashing the scikit-learn tests on those
systems.
Copy link
Member

@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.

Tested on an M1 laptop and this fix works.

Should this PR be reverted when numpy/numpy#19926 is merged & released?

# On macOS with a Apple Silicon M1 processor, we can get a spurious
# RuntimeWarning when executing this code. Let us just filter those
# warnings out. See: https://github.com/numpy/numpy/issues/18555
unwanted = [r for r in unwanted if r.category != RuntimeWarning]
Copy link
Member

Choose a reason for hiding this comment

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

This test is kind of flaky with warning_category=None since it catches everything, when I think it wants to focus on the deprecation warning. Maybe we can define unwanted depending on warning_category?

if warning_category is None:
    unwanted = [r for r in record if r.category == FutureWarning]
else:
    unwanted = [r for r in record if r.category != warning_category]

I think this fix will end up to be temporary, so I am okay with leaving the PR as is.

@ogrisel
Copy link
Member Author

ogrisel commented Oct 22, 2021

I had forgotten about this PR. Turned out that the problem was not limited to M1 and will be fixed in numpy 1.22 so #21396 is a better temporary fix.

@ogrisel ogrisel closed this Oct 22, 2021
@ogrisel ogrisel deleted the workaround-macos-m1-test-failure branch October 22, 2021 11:11
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

2 participants