Skip to content

Commit

Permalink
FIX ignore spurious RuntimeWarning in test on macOS M1 machines
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ogrisel committed Sep 16, 2021
1 parent 8fc3516 commit 6f36fee
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sklearn/linear_model/tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# License: BSD 3 clause

import platform
import pytest

import numpy as np
Expand Down Expand Up @@ -54,6 +55,11 @@ def test_linear_model_normalize_deprecation_message(
model.fit(X, y)
# Filter record in case other unrelated warnings are raised
unwanted = [r for r in record if r.category != warning_category]
if platform.system() == "Darwin" and platform.processor() == "arm":
# 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]
if len(unwanted):
msg = "unexpected warnings:\n"
for w in unwanted:
Expand Down

0 comments on commit 6f36fee

Please sign in to comment.