Skip to content

Commit 7584d8f

Browse files
ethanglaserCopilot
andauthored
Remove scipy version script and ignore incompatible sklearn test (#3018)
* isolate failing 2026 windows test * double -k * try skipping problematic test * skip additional seg faulting test * another one * another * ein ander * uno mas * anotha * 1 more * 1 more * deselect problematic scipy instead * experimenting with ignore instead of deselect * Delete scipy script * Clean up * black * Update deselected_tests.yaml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Restore get_scipy_version and set to 1.10 for skl1.0 * Deselect incompatible sklearn 1.0 / scipy 1.10 test --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 10b7455 commit 7584d8f

3 files changed

Lines changed: 64 additions & 62 deletions

File tree

Lines changed: 44 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,44 @@
1-
#! /usr/bin/env python
2-
# ===============================================================================
3-
# Copyright 2023 Intel Corporation
4-
#
5-
# Licensed under the Apache License, Version 2.0 (the "License");
6-
# you may not use this file except in compliance with the License.
7-
# You may obtain a copy of the License at
8-
#
9-
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
11-
# Unless required by applicable law or agreed to in writing, software
12-
# distributed under the License is distributed on an "AS IS" BASIS,
13-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
# See the License for the specific language governing permissions and
15-
# limitations under the License.
16-
# ===============================================================================
17-
from sys import argv, exit, stderr
18-
from sys import version_info as python_version
19-
20-
if len(argv) == 1:
21-
from daal4py.sklearn._utils import sklearn_check_version
22-
else:
23-
# This is necessary to prevent import errors from sklearnex and by extension
24-
# sklearn caused by initial scipy and/or numpy versions that are installed.
25-
# It is written in a way to be `packaging` independent. This branch occurs
26-
# when a sklearn version is given to the script externally.
27-
def sklearn_check_version(ver):
28-
ver = [int(i) if i != "" else 0 for i in ver.split(".")[:2]]
29-
sk_ver = [int(i) if i != "" else 0 for i in str(argv[1]).split(".")[:2]]
30-
return sk_ver[0] > ver[0] or (sk_ver[0] == ver[0] and sk_ver[1] >= ver[1])
31-
32-
33-
if sklearn_check_version("1.4"):
34-
print("Scipy version is not specified for this sklearn/python version.", file=stderr)
35-
print("scipy")
36-
elif sklearn_check_version("1.3") or python_version[1] > 11:
37-
if python_version[1] > 8:
38-
print("scipy==1.12.*")
39-
else:
40-
print("scipy==1.11.*")
41-
elif sklearn_check_version("1.2") or python_version[1] > 10:
42-
if python_version[1] > 9:
43-
print("scipy==1.12.*")
44-
else:
45-
print("scipy==1.9.*")
46-
elif sklearn_check_version("1.1"):
47-
print("scipy==1.8.*")
48-
elif sklearn_check_version("1.0"):
49-
print("scipy==1.7.*")
50-
else:
51-
print(
52-
"Scipy version defaults to not specified "
53-
"for this outdated sklearn/python version.",
54-
file=stderr,
55-
)
56-
print("scipy")
1+
#! /usr/bin/env python
2+
# ===============================================================================
3+
# Copyright 2023 Intel Corporation
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
# ===============================================================================
17+
from sys import argv, exit, stderr
18+
from sys import version_info as python_version
19+
20+
if len(argv) == 1:
21+
from daal4py.sklearn._utils import sklearn_check_version
22+
else:
23+
# This is necessary to prevent import errors from sklearnex and by extension
24+
# sklearn caused by initial scipy and/or numpy versions that are installed.
25+
# It is written in a way to be `packaging` independent. This branch occurs
26+
# when a sklearn version is given to the script externally.
27+
def sklearn_check_version(ver):
28+
ver = [int(i) if i != "" else 0 for i in ver.split(".")[:2]]
29+
sk_ver = [int(i) if i != "" else 0 for i in str(argv[1]).split(".")[:2]]
30+
return sk_ver[0] > ver[0] or (sk_ver[0] == ver[0] and sk_ver[1] >= ver[1])
31+
32+
33+
if sklearn_check_version("1.4"):
34+
print("Scipy version is not specified for this sklearn/python version.", file=stderr)
35+
print("scipy")
36+
elif sklearn_check_version("1.0"):
37+
print("scipy==1.10.*")
38+
else:
39+
print(
40+
"Scipy version defaults to not specified "
41+
"for this outdated sklearn/python version.",
42+
file=stderr,
43+
)
44+
print("scipy")

.circleci/deselect_tests.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,10 @@ def create_pytest_switches(
8181
with open(filename, "r") as fh:
8282
dt = yaml_load(fh, Loader=FullLoader)
8383

84+
sklearn_dir = os.path.dirname(sklearn.__file__)
85+
8486
if absolute:
85-
base_dir = (
86-
os.path.relpath(
87-
os.path.dirname(sklearn.__file__), os.path.expanduser("~")
88-
)
89-
+ "/"
90-
)
87+
base_dir = os.path.relpath(sklearn_dir, os.path.expanduser("~")) + "/"
9188
elif base_dir is None:
9289
base_dir = ""
9390
elif not base_dir.endswith("/"):
@@ -129,6 +126,14 @@ def create_pytest_switches(
129126
for test_name in filtered_deselection:
130127
if test_name:
131128
pytest_switches.extend(["--deselect=" + base_dir + test_name])
129+
130+
# Files that crash at collection time need --ignore instead of --deselect
131+
for entry in dt.get("ignored_tests", []):
132+
rel_path = filter_by_version_and_platform(entry, sklearn_version)
133+
if rel_path:
134+
pytest_switches.append(
135+
"--ignore=" + os.path.join(sklearn_dir, *rel_path.split("/"))
136+
)
132137
return pytest_switches
133138

134139

deselected_tests.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ deselected_tests:
7373
- neighbors/tests/test_neighbors.py::test_kneighbors_brute_backend[float64-kulsinski] <1.3
7474
- neighbors/tests/test_neighbors.py::test_radius_neighbors_brute_backend[kulsinski] <1.3
7575

76+
# wminkowski removed in scipy 1.8 but sklearn <=1.1 NearestNeighbors._fit() lacks kd_tree + weighted minkowski check
77+
- neighbors/tests/test_neighbors.py::test_neighbors_metrics <=1.1
78+
7679
# sklearnex PCA always chooses "covariance_eigh" solver instead of "full" when solver="auto"
7780
# resulting in solver assignment check failure for sklearn version >= 1.5
7881
- decomposition/tests/test_pca.py::test_pca_svd_solver_auto[1000-500-400-full] >=1.5
@@ -552,3 +555,9 @@ gpu:
552555
- tests/test_common.py::test_estimators[RandomForestRegressor(n_estimators=5)-check_regressor_data_not_an_array]
553556
- tests/test_common.py::test_estimators[RandomForestClassifier(n_estimators=5)-check_class_weight_classifiers]
554557
- tests/test_common.py::test_estimators[ExtraTreesClassifier(n_estimators=5)-check_class_weight_classifiers]
558+
559+
# --------------------------------------------------------
560+
# The following tests fail at collection time, so they cannot be deselected with --deselect and must be ignored with --ignore.
561+
ignored_tests:
562+
# scipy.misc.face was removed; test_image.py calls it at module level
563+
- feature_extraction/tests/test_image.py <1.2

0 commit comments

Comments
 (0)