Skip to content

Commit 37f27ee

Browse files
authored
MNT add documentation testing in Azure (#715)
1 parent b037591 commit 37f27ee

File tree

10 files changed

+81
-73
lines changed

10 files changed

+81
-73
lines changed

.travis.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ cache:
1313
- $HOME/.cache/pip
1414
- $HOME/.cache/pip
1515
- $HOME/download
16-
addons:
17-
apt:
18-
packages:
19-
- python3-numpy
20-
- python3-scipy
16+
2117
env:
2218
global:
2319
# Directory where tests are run from
@@ -28,15 +24,7 @@ env:
2824

2925
matrix:
3026
include:
31-
- env: PYTHON_VERSION="3.7"
32-
NUMPY_VERSION="*" SCIPY_VERSION="*" SKLEARN_VERSION="master"
33-
OPTIONAL_DEPS="keras" TEST_DOC="true" TEST_NUMPYDOC="false"
34-
- env: PYTHON_VERSION="3.7"
35-
NUMPY_VERSION="*" SCIPY_VERSION="*" SKLEARN_VERSION="master"
36-
OPTIONAL_DEPS="tensorflow" TEST_DOC="true" TEST_NUMPYDOC="false"
37-
- env: PYTHON_VERSION="3.7"
38-
NUMPY_VERSION="*" SCIPY_VERSION="*" SKLEARN_VERSION="master"
39-
OPTIONAL_DEPS="false" TEST_DOC="false" TEST_NUMPYDOC="true"
27+
- env: PYTHON_VERSION="3.8" TEST_DOC="true" TEST_NUMPYDOC="true"
4028

4129
install: source build_tools/travis/install.sh
4230
script: bash build_tools/travis/test_script.sh

azure-pipelines.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
# Linux environment to test the latest available dependencies and MKL.
3333
pylatest_pip_openblas_pandas:
3434
DISTRIB: 'conda-pip-latest'
35-
PYTHON_VERSION: '3.7'
35+
PYTHON_VERSION: '3.8'
3636
COVERAGE: 'true'
3737
PANDAS_VERSION: '*'
3838
TEST_DOCSTRINGS: 'true'
@@ -49,7 +49,7 @@ jobs:
4949
TEST_DOCSTRINGS: 'true'
5050
pylatest_conda_pandas_tensorflow:
5151
DISTRIB: 'conda'
52-
PYTHON_VERSION: '3.7'
52+
PYTHON_VERSION: '3.8'
5353
PANDAS_VERSION: '*'
5454
JOBLIB_VERSION: '*'
5555
INSTALL_MKL: 'true'
@@ -95,7 +95,7 @@ jobs:
9595
dependsOn: [linting]
9696
matrix:
9797
py37_conda_mkl:
98-
PYTHON_VERSION: '3.7'
98+
PYTHON_VERSION: '3.8'
9999
PYTHON_ARCH: '64'
100100
PYTEST_VERSION: '*'
101101
COVERAGE: 'true'

build_tools/azure/posix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
condition: succeededOrFailed()
4545
- script: |
4646
build_tools/azure/upload_codecov.sh
47-
condition: and(succeeded(), eq(variables['COVERAGE'], 'true'), eq(variables['DISTRIB'], 'conda'))
47+
condition: and(succeeded(), eq(variables['COVERAGE'], 'true'))
4848
displayName: 'Upload To Codecov'
4949
env:
5050
CODECOV_TOKEN: $(CODECOV_TOKEN)

build_tools/azure/test_docs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ elif [[ "$DISTRIB" == "ubuntu" ]]; then
88
source $VIRTUALENV/bin/activate
99
fi
1010

11-
if [[ "TEST_DOCSTRING" == 'true' ]]; then
11+
if [[ "$TEST_DOCSTRINGS" == 'true' ]]; then
1212
make test-doc
1313
pytest -vsl maint_tools/test_docstring.py
1414
fi

build_tools/travis/install.sh

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,13 @@ conda create -n testenv --yes python=$PYTHON_VERSION pip
3434
source activate testenv
3535

3636
pip install --upgrade pip setuptools
37-
echo "Installing numpy and scipy master wheels"
38-
dev_url=https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com
39-
pip install --pre --upgrade --timeout=60 -f $dev_url numpy scipy pandas cython
37+
echo "Installing numpy, scipy, and pandas master wheels"
38+
dev_url=https://pypi.anaconda.org/scipy-wheels-nightly/simple
39+
pip install --pre --upgrade --timeout=60 -f $dev_url numpy scipy pandas
4040
echo "Installing joblib master"
4141
pip install https://github.com/joblib/joblib/archive/master.zip
42-
43-
if [[ "$OPTIONAL_DEPS" == "keras" ]]; then
44-
conda install --yes keras tensorflow=1
45-
KERAS_BACKEND=tensorflow
46-
python -c "import keras.backend"
47-
sed -i -e 's/"backend":[[:space:]]*"[^"]*/"backend":\ "'$KERAS_BACKEND'/g' ~/.keras/keras.json;
48-
elif [[ "$OPTIONAL_DEPS" == "tensorflow" ]]; then
49-
conda install --yes tensorflow
50-
fi
51-
52-
pip install --pre --extra-index https://pypi.anaconda.org/scipy-wheels-nightly/simple scikit-learn
42+
echo "Installing scikit-learn master"
43+
pip install --pre --extra-index $dev_url scikit-learn
5344

5445
conda install --yes pytest pytest-cov
5546
pip install codecov

doc/ensemble.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ a boosting iteration :cite:`seiffert2009rusboost`::
9797
RUSBoostClassifier(...)
9898
>>> y_pred = rusboost.predict(X_test)
9999
>>> balanced_accuracy_score(y_test, y_pred) # doctest: +ELLIPSIS
100-
0.4...
100+
0...
101101

102102
A specific method which uses ``AdaBoost`` as learners in the bagging classifier
103103
is called EasyEnsemble. The :class:`EasyEnsembleClassifier` allows to bag

imblearn/over_sampling/_smote.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,8 +744,7 @@ def _fit_resample(self, X, y):
744744
# sampling_strategy=BaseOverSampler._sampling_strategy_docstring,
745745
# random_state=_random_state_docstring)
746746
class SMOTENC(SMOTE):
747-
"""Synthetic Minority Over-sampling Technique for Nominal and Continuous
748-
(SMOTE-NC).
747+
"""Synthetic Minority Over-sampling Technique for Nominal and Continuous.
749748
750749
Unlike :class:`SMOTE`, SMOTE-NC for dataset containing continuous and
751750
categorical features.

imblearn/pipeline.py

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Pipeline(pipeline.Pipeline):
4747
fit/transform/fit_resample) that are chained, in the order in which
4848
they are chained, with the last object an estimator.
4949
50-
memory : Instance of joblib.Memory or string, optional (default=None)
50+
memory : Instance of joblib.Memory or str, default=None
5151
Used to cache the fitted transformers of the pipeline. By default,
5252
no caching is performed. If a string is given, it is the path to
5353
the caching directory. Enabling caching triggers a clone of
@@ -57,7 +57,7 @@ class Pipeline(pipeline.Pipeline):
5757
inspect estimators within the pipeline. Caching the
5858
transformers is advantageous when fitting is time consuming.
5959
60-
verbose : boolean, optional (default=False)
60+
verbose : bool, default=False
6161
If True, the time elapsed while fitting each step will be printed as it
6262
is completed.
6363
@@ -67,17 +67,16 @@ class Pipeline(pipeline.Pipeline):
6767
Read-only attribute to access any step parameter by user given name.
6868
Keys are step names and values are steps parameters.
6969
70+
See Also
71+
--------
72+
make_pipeline : Helper function to make pipeline.
73+
7074
Notes
7175
-----
7276
See :ref:`sphx_glr_auto_examples_pipeline_plot_pipeline_classification.py`
7377
74-
See also
75-
--------
76-
make_pipeline : helper function to make pipeline.
77-
7878
Examples
7979
--------
80-
8180
>>> from collections import Counter
8281
>>> from sklearn.datasets import make_classification
8382
>>> from sklearn.model_selection import train_test_split as tts
@@ -109,7 +108,6 @@ class Pipeline(pipeline.Pipeline):
109108
macro avg 0.93 0.99 0.96 250
110109
weighted avg 0.99 0.98 0.98 250
111110
<BLANKLINE>
112-
113111
"""
114112

115113
# BaseEstimator interface
@@ -257,7 +255,7 @@ def _fit(self, X, y=None, **fit_params):
257255
return X, y, fit_params_steps[self.steps[-1][0]]
258256

259257
def fit(self, X, y=None, **fit_params):
260-
"""Fit the model
258+
"""Fit the model.
261259
262260
Fit all the transforms/samplers one after the other and
263261
transform/sample the data, then fit the transformed/sampled
@@ -273,16 +271,15 @@ def fit(self, X, y=None, **fit_params):
273271
Training targets. Must fulfill label requirements for all steps of
274272
the pipeline.
275273
276-
**fit_params : dict of string -> object
274+
**fit_params : dict of str -> object
277275
Parameters passed to the ``fit`` method of each step, where
278276
each parameter name is prefixed such that parameter ``p`` for step
279277
``s`` has key ``s__p``.
280278
281279
Returns
282280
-------
283281
self : Pipeline
284-
This estimator
285-
282+
This estimator.
286283
"""
287284
Xt, yt, fit_params = self._fit(X, y, **fit_params)
288285
with _print_elapsed_time('Pipeline',
@@ -292,7 +289,7 @@ def fit(self, X, y=None, **fit_params):
292289
return self
293290

294291
def fit_transform(self, X, y=None, **fit_params):
295-
"""Fit the model and transform with the final estimator
292+
"""Fit the model and transform with the final estimator.
296293
297294
Fits all the transformers/samplers one after the other and
298295
transform/sample the data, then uses fit_transform on
@@ -315,9 +312,8 @@ def fit_transform(self, X, y=None, **fit_params):
315312
316313
Returns
317314
-------
318-
Xt : array-like, shape = [n_samples, n_transformed_features]
319-
Transformed samples
320-
315+
Xt : array-like of shape (n_samples, n_transformed_features)
316+
Transformed samples.
321317
"""
322318
last_step = self._final_estimator
323319
Xt, yt, fit_params = self._fit(X, y, **fit_params)
@@ -331,7 +327,7 @@ def fit_transform(self, X, y=None, **fit_params):
331327
return last_step.fit(Xt, yt, **fit_params).transform(Xt)
332328

333329
def fit_resample(self, X, y=None, **fit_params):
334-
"""Fit the model and sample with the final estimator
330+
"""Fit the model and sample with the final estimator.
335331
336332
Fits all the transformers/samplers one after the other and
337333
transform/sample the data, then uses fit_resample on transformed
@@ -354,12 +350,11 @@ def fit_resample(self, X, y=None, **fit_params):
354350
355351
Returns
356352
-------
357-
Xt : array-like, shape = [n_samples, n_transformed_features]
358-
Transformed samples
359-
360-
yt : array-like, shape = [n_samples, n_transformed_features]
361-
Transformed target
353+
Xt : array-like of shape (n_samples, n_transformed_features)
354+
Transformed samples.
362355
356+
yt : array-like of shape (n_samples, n_transformed_features)
357+
Transformed target.
363358
"""
364359
last_step = self._final_estimator
365360
Xt, yt, fit_params = self._fit(X, y, **fit_params)
@@ -372,7 +367,7 @@ def fit_resample(self, X, y=None, **fit_params):
372367

373368
@if_delegate_has_method(delegate="_final_estimator")
374369
def fit_predict(self, X, y=None, **fit_params):
375-
"""Applies fit_predict of last step in pipeline after transforms.
370+
"""Apply `fit_predict` of last step in pipeline after transforms.
376371
377372
Applies fit_transforms of a pipeline to the data, followed by the
378373
fit_predict method of the final estimator in the pipeline. Valid
@@ -395,7 +390,8 @@ def fit_predict(self, X, y=None, **fit_params):
395390
396391
Returns
397392
-------
398-
y_pred : array-like
393+
y_pred : ndarray of shape (n_samples,)
394+
The predicted target.
399395
"""
400396
Xt, yt, fit_params = self._fit(X, y, **fit_params)
401397
with _print_elapsed_time('Pipeline',
@@ -425,9 +421,10 @@ def make_pipeline(*steps, **kwargs):
425421
426422
Parameters
427423
----------
428-
*steps : list of estimators.
424+
*steps : list of estimators
425+
A list of estimators.
429426
430-
memory : None, str or object with the joblib.Memory interface, optional
427+
memory : None, str or object with the joblib.Memory interface, default=None
431428
Used to cache the fitted transformers of the pipeline. By default,
432429
no caching is performed. If a string is given, it is the path to
433430
the caching directory. Enabling caching triggers a clone of
@@ -437,15 +434,15 @@ def make_pipeline(*steps, **kwargs):
437434
inspect estimators within the pipeline. Caching the
438435
transformers is advantageous when fitting is time consuming.
439436
440-
verbose : boolean, optional (default=False)
437+
verbose : bool, default=False
441438
If True, the time elapsed while fitting each step will be printed as it
442439
is completed.
443440
444441
Returns
445442
-------
446443
p : Pipeline
447444
448-
See also
445+
See Also
449446
--------
450447
imblearn.pipeline.Pipeline : Class for creating a pipeline of
451448
transforms with a final estimator.

imblearn/under_sampling/_prototype_generation/_cluster_centroids.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def __init__(
102102
random_state=None,
103103
estimator=None,
104104
voting="auto",
105-
n_jobs="deprecatedxs",
105+
n_jobs="deprecated",
106106
):
107107
super().__init__(sampling_strategy=sampling_strategy)
108108
self.random_state = random_state

maint_tools/test_docstring.py

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,47 @@
1010
# List of whitelisted modules and methods; regexp are supported.
1111
# These docstrings will fail because they are inheriting from scikit-learn
1212
DOCSTRING_WHITELIST = [
13-
"BalancedBaggingClassifier.decision_function",
14-
"BalancedRandomForestClassifier.decision_function",
15-
"BalancedRandomForestClassifier.decision_path",
13+
"ADASYN$", "ADASYN.",
14+
"AllKNN$", "AllKNN.",
15+
"BalancedBaggingClassifier$",
16+
"BalancedBaggingClassifier.estimators_samples_",
17+
"BalancedBaggingClassifier.fit",
18+
"BalancedBaggingClassifier.get_params",
19+
"BalancedBaggingClassifier.predict",
20+
"BalancedBaggingClassifier.score",
21+
"BalancedBaggingClassifier.set_params",
22+
"BalancedRandomForestClassifier$",
23+
"BalancedRandomForestClassifier.apply",
1624
"BalancedRandomForestClassifier.feature_importances_",
17-
"BalancedRandomForestClassifier.predict_log_proba",
18-
"BalancedRandomForestClassifier.predict_proba",
19-
"EasyEnsembleClassifier.decision_function",
20-
"RUSBoostClassifier.feature_importances_"
25+
"BalancedRandomForestClassifier.fit",
26+
"BalancedRandomForestClassifier.predict$",
27+
"BalancedRandomForestClassifier.score",
28+
"BalancedRandomForestClassifier.set_params",
29+
"ClusterCentroids$", "ClusterCentroids.",
30+
"CondensedNearestNeighbour$", "CondensedNearestNeighbour.",
31+
"EasyEnsembleClassifier$",
32+
"EasyEnsembleClassifier.estimators_samples_",
33+
"EasyEnsembleClassifier.fit",
34+
"EasyEnsembleClassifier.get_params",
35+
"EasyEnsembleClassifier.predict",
36+
"EasyEnsembleClassifier.score",
37+
"EasyEnsembleClassifier.set_params",
38+
"EditedNearestNeighbours$", "EditedNearestNeighbours.",
39+
"FunctionSampler$", "FunctionSampler.",
40+
"InstanceHardnessThreshold$", "InstanceHardnessThreshold.",
41+
"SMOTE$", "SMOTE.",
42+
"NearMiss$", "NearMiss.",
43+
"NeighbourhoodCleaningRule$", "NeighbourhoodCleaningRule.",
44+
"OneSidedSelection$", "OneSidedSelection.",
45+
"Pipeline$",
46+
"Pipeline.fit$",
47+
"Pipeline.fit_transform",
48+
"Pipeline.fit_resample",
49+
"Pipeline.fit_predict",
50+
"RUSBoostClassifier$", "RUSBoostClassifier.",
51+
"RandomOverSampler$", "RandomOverSampler.",
52+
"RandomUnderSampler$", "RandomUnderSampler.",
53+
"TomekLinks$", "TomekLinks",
2154
]
2255

2356

@@ -137,7 +170,7 @@ def test_docstring(Estimator, method, request):
137170

138171
import_path = ".".join(import_path)
139172

140-
if any(re.search(regex, import_path) for regex in DOCSTRING_WHITELIST):
173+
if not any(re.search(regex, import_path) for regex in DOCSTRING_WHITELIST):
141174
request.applymarker(
142175
pytest.mark.xfail(
143176
run=False, reason="TODO pass numpydoc validation"

0 commit comments

Comments
 (0)