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

Skip to content

Commit e522e01

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

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

sklearn/metrics/_plot/tests/test_precision_recall_display.py

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

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

712
from sklearn.compose import make_column_transformer
813
from sklearn.datasets import load_breast_cancer, make_classification

sklearn/metrics/_plot/tests/test_roc_curve_display.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import numpy as np
22
import pytest
33
from numpy.testing import assert_allclose
4-
from scipy.integrate import trapz as trapezoid
4+
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
510

611
from sklearn.compose import make_column_transformer
712
from sklearn.datasets import load_breast_cancer, load_iris

sklearn/metrics/_ranking.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@
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
3029

30+
try:
31+
from scipy.integrate import trapezoid
32+
except ImportError:
33+
# NOTE: remove once 1.6.0 is minimum supported scipy version
34+
from scipy.integrate import trapz as trapezoid
35+
3136
from ..exceptions import UndefinedMetricWarning
3237
from ..preprocessing import label_binarize
3338
from ..utils import (

0 commit comments

Comments
 (0)
0