8000 MAINT Upgrade CI to PyPy 7.1.1, fix CI failure on master (#13912) · rth/scikit-learn@be17713 · GitHub
[go: up one dir, main page]

Skip to content

Commit be17713

Browse files
authored
MAINT Upgrade CI to PyPy 7.1.1, fix CI failure on master (scikit-learn#13912)
1 parent 7f50e82 commit be17713

File tree

6 files changed

+30
-11
lines changed

6 files changed

+30
-11
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777

7878
pypy3:
7979
docker:
80-
- image: pypy:3-7.0.0
80+
- image: pypy:3.6-7.1.1
8181
steps:
8282
- restore_cache:
8383
keys:

build_tools/circle/build_test_pypy.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,23 @@ which python
2121
# XXX: numpy version pinning can be reverted once PyPy
2222
# compatibility is resolved for numpy v1.6.x. For instance,
2323
# when PyPy3 >6.0 is released (see numpy/numpy#12740)
24-
pip install --extra-index https://antocuni.github.io/pypy-wheels/ubuntu "numpy==1.15.*" Cython pytest
25-
pip install "scipy>=1.1.0" sphinx numpydoc docutils joblib pillow
24+
pip install --extra-index https://antocuni.github.io/pypy-wheels/ubuntu numpy Cython pytest
25+
pip install scipy sphinx numpydoc docutils joblib pillow
2626

2727
ccache -M 512M
2828
export CCACHE_COMPRESS=1
2929
export PATH=/usr/lib/ccache:$PATH
3030
export LOKY_MAX_CPU_COUNT="2"
31+
export OMP_NUM_THREADS="1"
3132

32-
pip install -vv -e .
33+
pip install -e .
34+
35+
# Check that Python implementation is PyPy
36+
python - << EOL
37+
import platform
38+
from sklearn.utils import IS_PYPY
39+
assert IS_PYPY is True, "platform={}!=PyPy".format(platform.python_implementation())
40+
EOL
3341

3442
python -m pytest sklearn/
3543
python -m pytest doc/sphinxext/

sklearn/datasets/tests/test_base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
from sklearn.utils.testing import assert_equal
3131
from sklearn.utils.testing import assert_raises
32+
from sklearn.utils import IS_PYPY
3233

3334

3435
def _remove_dir(path):
@@ -92,6 +93,8 @@ def test_default_empty_load_files(load_files_root):
9293

9394
def test_default_load_files(test_category_dir_1, test_category_dir_2,
9495
load_files_root):
96+
if IS_PYPY:
97+
pytest.xfail('[PyPy] fails due to string containing NUL characters')
9598
res = load_files(load_files_root)
9699
assert_equal(len(res.filenames), 1)
97100
assert_equal(len(res.target_names), 2)
@@ -101,6 +104,8 @@ def test_default_load_files(test_category_dir_1, test_category_dir_2,
101104

102105
def test_load_files_w_categories_desc_and_encoding(
103106
test_category_dir_1, test_category_dir_2, load_files_root):
107+
if IS_PYPY:
108+
pytest.xfail('[PyPy] fails due to string containing NUL characters')
104109
category = os.path.abspath(test_category_dir_1).split('/').pop()
105110
res = load_files(load_files_root, description="test",
106111
categories=category, encoding="utf-8")

sklearn/ensemble/_hist_gradient_boosting/tests/test_gradient_boosting.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_early_stopping_regression(scoring, validation_fraction,
6666

6767
max_iter = 200
6868

69-
X, y = make_regression(random_state=0)
69+
X, y = make_regression(n_samples=50, random_state=0)
7070

7171
gb = HistGradientBoostingRegressor(
7272
verbose=1, # just for coverage
@@ -87,8 +87,9 @@ def test_early_stopping_regression(scoring, validation_fraction,
8787

8888

8989
@pytest.mark.parametrize('data', (
90-
make_classification(random_state=0),
91-
make_classification(n_classes=3, n_clusters_per_class=1, random_state=0)
90+
make_classification(n_samples=30, random_state=0),
91+
make_classification(n_samples=30, n_classes=3, n_clusters_per_class=1,
92+
random_state=0)
9293
))
9394
@pytest.mark.parametrize(
9495
'scoring, validation_fraction, n_iter_no_change, tol', [

sklearn/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class NotFittedError(ValueError, AttributeError):
3030
... except NotFittedError as e:
3131
... print(repr(e))
3232
NotFittedError("This LinearSVC instance is not fitted yet. Call 'fit' with
33-
appropriate arguments before using this method.")
33+
appropriate arguments before using this method."...)
3434
3535
.. versionchanged:: 0.18
3636
Moved from sklearn.utils.validation.

sklearn/feature_extraction/tests/test_text.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ def test_vectorizers_invalid_ngram_range(vec):
10921092
"lower boundary larger than the upper boundary."
10931093
% str(invalid_range))
10941094
if isinstance(vec, HashingVectorizer):
1095-
pytest.xfail(reason='HashingVectorizer not supported on PyPy')
1095+
pytest.xfail(reason='HashingVectorizer is not supported on PyPy')
10961096

10971097
assert_raise_message(
10981098
ValueError, message, vec.fit, ["good news everyone"])
@@ -1199,14 +1199,16 @@ def build_preprocessor(self):
11991199
'Estimator',
12001200
[CountVectorizer,
12011201
TfidfVectorizer,
1202-
pytest.param(HashingVectorizer, marks=fails_if_pypy)]
1202+
HashingVectorizer]
12031203
)
12041204
@pytest.mark.parametrize(
12051205
'input_type, err_type, err_msg',
12061206
[('filename', FileNotFoundError, ''),
12071207
('file', AttributeError, "'str' object has no attribute 'read'")]
12081208
)
12091209
def test_callable_analyzer_error(Estimator, input_type, err_type, err_msg):
1210+
if issubclass(Estimator, HashingVectorizer):
1211+
pytest.xfail('HashingVectorizer is not supported on PyPy')
12101212
data = ['this is text, not file or filename']
12111213
with pytest.raises(err_type, match=err_msg):
12121214
Estimator(analyzer=lambda x: x.split(),
@@ -1237,13 +1239,16 @@ def test_callable_analyzer_change_behavior(Estimator, analyzer, input_type):
12371239
'Estimator',
12381240
[CountVectorizer,
12391241
TfidfVectorizer,
1240-
pytest.param(HashingVectorizer, marks=fails_if_pypy)]
1242+
HashingVectorizer]
12411243
)
12421244
def test_callable_analyzer_reraise_error(tmpdir, Estimator):
12431245
# check if a custom exception from the analyzer is shown to the user
12441246
def analyzer(doc):
12451247
raise Exception("testing")
12461248

1249+
if issubclass(Estimator, HashingVectorizer):
1250+
pytest.xfail('HashingVectorizer is not supported on PyPy')
1251+
12471252
f = tmpdir.join("file.txt")
12481253
f.write("sample content\n")
12491254

0 commit comments

Comments
 (0)
0