Skip to content

Commit a067eb1

Browse files
authored
Fix CI with scikit-learn related fixes (#157)
1 parent 4a974fd commit a067eb1

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ env:
1111
- CIBW_BEFORE_BUILD="pip install numpy==1.17.3 scipy==1.3.2 cython==0.29.14 setuptools"
1212
- CIBW_TEST_REQUIRES="pytest scikit-learn gstools"
1313
- CIBW_TEST_COMMAND="pytest -v {project}/tests"
14+
- OMP_NUM_THREADS=2
1415

1516
before_install:
1617
- |

examples/krige_cv.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import numpy as np
1010
from pykrige.rk import Krige
11-
from pykrige.compat import GridSearchCV
11+
from sklearn.model_selection import GridSearchCV
1212

1313

1414
# 2D Kring param opt
@@ -20,7 +20,7 @@
2020
# "weight": [True, False]
2121
}
2222

23-
estimator = GridSearchCV(Krige(), param_dict, verbose=True)
23+
estimator = GridSearchCV(Krige(), param_dict, verbose=True, return_train_score=True)
2424

2525
# dummy data
2626
X = np.random.randint(0, 400, size=(100, 2)).astype(float)

pykrige/compat.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# coding: utf-8
22
# pylint: disable= invalid-name, unused-import
33
"""For compatibility"""
4-
import inspect
54
from functools import partial
65

76

@@ -11,12 +10,6 @@
1110
from sklearn.model_selection import train_test_split
1211

1312
SKLEARN_INSTALLED = True
14-
arg_spec = inspect.getfullargspec(GridSearchCV)[0]
15-
# https://stackoverflow.com/a/56618067/6696397
16-
if "return_train_score" in arg_spec:
17-
GridSearchCV = partial(GridSearchCV, return_train_score=True)
18-
if "iid" in arg_spec:
19-
GridSearchCV = partial(GridSearchCV, iid=False)
2013

2114
except ImportError:
2215
SKLEARN_INSTALLED = False

tests/test_api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from itertools import product
22

33
import numpy as np
4+
import pytest
45

56
from pykrige.rk import Krige
67
from pykrige.rk import threed_krige
7-
from pykrige.compat import GridSearchCV
88

99

1010
def _method_and_vergiogram():
@@ -15,6 +15,9 @@ def _method_and_vergiogram():
1515

1616
def test_krige():
1717
# dummy data
18+
pytest.importorskip("sklearn")
19+
from sklearn.model_selection import GridSearchCV
20+
1821
np.random.seed(1)
1922
X = np.random.randint(0, 400, size=(20, 3)).astype(float)
2023
y = 5 * np.random.rand(20)
@@ -28,6 +31,7 @@ def test_krige():
2831
n_jobs=-1,
2932
pre_dispatch="2*n_jobs",
3033
verbose=False,
34+
return_train_score=True,
3135
cv=5,
3236
)
3337
# run the gridsearch

0 commit comments

Comments
 (0)