8000 add try except for trapezoid import · scikit-learn/scikit-learn@0a406d6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0a406d6

Browse files
committed
add try except for trapezoid import
1 parent 174241f commit 0a406d6

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

sklearn/metrics/_plot/tests/test_precision_recall_display.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
import numpy as np
44
import pytest
5-
from scipy.integrate import trapz as trapezoid
5+
try:
6+
from scipy.integrate import trapezoid
7+
except ImportError:
8+
# NOTE: remove once 1.6.0 is minimum supported scipy version
9+
from scipy.integrate import trapz as trapezoid
610

711
from sklearn.compose import make_column_transformer
812
from sklearn.datasets import load_breast_cancer, make_classification

sklearn/metrics/_plot/tests/test_roc_curve_display.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import numpy as np
22
import pytest
33
from numpy.testing import assert_allclose
4-
from scipy.integrate import trapz as trapezoid
4+
try:
5+
from scipy.integrate import trapezoid
6+
except ImportError:
7+
# NOTE: remove once 1.6.0 is minimum supported scipy version
8+
from scipy.integrate import trapz as trapezoid
59

610
from sklearn.compose import make_column_transformer
711
from sklearn.datasets import load_breast_cancer, load_iris

sklearn/metrics/_ranking.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@
2424
from numbers import Integral, Real
2525

2626
import numpy as np
27-
from scipy.integrate import trapz as trapezoid
2827
from scipy.sparse import csr_matrix, issparse
2928
from scipy.stats import rankdata
29+
try:
30+
from scipy.integrate import trapezoid
31+
except ImportError:
32+
# NOTE: remove once 1.6.0 is minimum supported scipy version
33+
from scipy.integrate import trapz as trapezoid
3034

3135
from ..exceptions import UndefinedMetricWarning
3236
from ..preprocessing import label_binarize

0 commit comments

Comments
 (0)
0