Skip to content

Commit f695fb7

Browse files
authored
CI Add more platform for testing (#309)
[MRG] Add more platform for testing
1 parent dd941e7 commit f695fb7

30 files changed

+150
-103
lines changed

.travis.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
# make it explicit that we favor the new container-based travis workers
2+
dist: trusty
23
sudo: false
34

45
language: python
5-
python:
6-
- 2.7
6+
77
# Pre-install packages for the ubuntu distribution
88
cache:
99
apt: true
1010
# We use three different cache directory
1111
# to work around a Travis bug with multi-platform cache
1212
directories:
1313
- $HOME/.cache/pip
14+
- $HOME/.cache/pip
1415
- $HOME/download
1516
addons:
1617
apt:
1718
packages:
18-
- libatlas3gf-base
19-
- libatlas-dev
20-
- gfortran
21-
- libgfortran3
19+
- python-numpy
20+
- python-scipy
2221
env:
2322
global:
2423
# Directory where tests are run from
@@ -28,10 +27,17 @@ env:
2827
- OPENBLAS_NUM_THREADS=4
2928
matrix:
3029
# This environment tests the using anaconda
30+
# Ubuntu 14.04 environment
31+
- DISTRIB="ubuntu"
32+
# Latest release
3133
- DISTRIB="conda" PYTHON_VERSION="2.7"
32-
NUMPY_VERSION="1.11.2" SCIPY_VERSION="0.18.1" SKLEARN_VERSION="0.18.1"
34+
NUMPY_VERSION="1.13.1" SCIPY_VERSION="0.19.1" SKLEARN_VERSION="0.18.2"
35+
- DISTRIB="conda" PYTHON_VERSION="3.4"
36+
NUMPY_VERSION="1.11.3" SCIPY_VERSION="0.18.1" SKLEARN_VERSION="0.18.1"
3337
- DISTRIB="conda" PYTHON_VERSION="3.5"
34-
NUMPY_VERSION="1.11.2" SCIPY_VERSION="0.18.1" SKLEARN_VERSION="0.18.1"
38+
NUMPY_VERSION="1.13.1" SCIPY_VERSION="0.19.1" SKLEARN_VERSION="0.18.2"
39+
- DISTRIB="conda" PYTHON_VERSION="3.6"
40+
NUMPY_VERSION="1.13.1" SCIPY_VERSION="0.19.1" SKLEARN_VERSION="0.18.2"
3541

3642
install: source build_tools/travis/install.sh
3743
script: bash build_tools/travis/test_script.sh

README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ Installation
5555
Dependencies
5656
~~~~~~~~~~~~
5757

58-
imbalanced-learn is tested to work under Python 2.7 and Python 3.4,
59-
3.5, and 3.6.
58+
imbalanced-learn is tested to work under Python 2.7 and Python 3.4, 3.5, and
59+
3.6. The dependency requirements are based on the last scikit-learn release:
6060

61-
* scipy(>=0.18.1)
62-
* numpy(>=1.11.2)
61+
* scipy(>=0.13.3)
62+
* numpy(>=1.8.2)
6363
* scikit-learn(>=0.18.1)
6464

6565
Additionally, to run the examples, you need matplotlib(>=2.0.0).

appveyor.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,26 @@ environment:
99
PYTHON_VERSION: "2.7.x"
1010
PYTHON_ARCH: "64"
1111

12+
- PYTHON: "C:\\Miniconda-x64"
13+
PYTHON_VERSION: "2.7.x"
14+
PYTHON_ARCH: "32"
15+
16+
- PYTHON: "C:\\Miniconda3-x64"
17+
PYTHON_VERSION: "3.4.x"
18+
PYTHON_ARCH: "64"
19+
1220
- PYTHON: "C:\\Miniconda3-x64"
1321
PYTHON_VERSION: "3.5.x"
1422
PYTHON_ARCH: "64"
1523

24+
- PYTHON: "C:\\Miniconda3-x64"
25+
PYTHON_VERSION: "3.6.x"
26+
PYTHON_ARCH: "64"
27+
28+
- PYTHON: "C:\\Miniconda3-x64"
29+
PYTHON_VERSION: "3.6.x"
30+
PYTHON_ARCH: "32"
31+
1632
install:
1733
# Prepend miniconda installed Python to the PATH of this build
1834
# Add Library/bin directory to fix issue

build_tools/travis/install.sh

100644100755
Lines changed: 60 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,66 @@
1-
# Deactivate the travis-provided virtual environment and setup a
2-
# conda-based environment instead
3-
deactivate
4-
5-
# Use the miniconda installer for faster download / install of conda
6-
# itself
7-
pushd .
8-
cd
9-
mkdir -p download
10-
cd download
11-
echo "Cached in $HOME/download :"
12-
ls -l
13-
echo
14-
if [[ ! -f miniconda.sh ]]
15-
then
16-
wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh \
1+
#!/bin/bash
2+
# This script is meant to be called by the "install" step defined in
3+
# .travis.yml. See http://docs.travis-ci.com/ for more details.
4+
# The behavior of the script is controlled by environment variabled defined
5+
# in the .travis.yml in the top level folder of the project.
6+
7+
# License: 3-clause BSD
8+
9+
# Travis clone pydicom/pydicom repository in to a local repository.
10+
11+
set -e
12+
13+
echo 'List files from cached directories'
14+
echo 'pip:'
15+
ls $HOME/.cache/pip
16+
17+
export CC=/usr/lib/ccache/gcc
18+
export CXX=/usr/lib/ccache/g++
19+
# Useful for debugging how ccache is used
20+
# export CCACHE_LOGFILE=/tmp/ccache.log
21+
# ~60M is used by .ccache when compiling from scratch at the time of writing
22+
ccache --max-size 100M --show-stats
23+
24+
if [[ "$DISTRIB" == "conda" ]]; then
25+
# Deactivate the travis-provided virtual environment and setup a
26+
# conda-based environment instead
27+
deactivate
28+
29+
# Install miniconda
30+
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \
1731
-O miniconda.sh
18-
fi
19-
chmod +x miniconda.sh && ./miniconda.sh -b
20-
cd ..
21-
export PATH=/home/travis/miniconda2/bin:$PATH
22-
conda update --yes conda
23-
popd
24-
25-
# Configure the conda environment and put it in the path using the
26-
# provided versions
27-
conda create -n testenv --yes python=$PYTHON_VERSION pip nose
28-
numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION \
29-
libgfortran nomkl
30-
source activate testenv
31-
32-
# Install scikit-learn
33-
conda install --yes scikit-learn=$SKLEARN_VERSION
34-
35-
# Install nose-timer via pip
36-
pip install nose-timer coverage codecov
37-
38-
# Build imbalanced-learn in the install.sh script to collapse the verbose
39-
# build output in the travis output when it succeeds.
32+
MINICONDA_PATH=/home/travis/miniconda
33+
chmod +x miniconda.sh && ./miniconda.sh -b -p $MINICONDA_PATH
34+
export PATH=$MINICONDA_PATH/bin:$PATH
35+
conda update --yes conda
36+
37+
# Configure the conda environment and put it in the path using the
38+
# provided versions
39+
conda create -n testenv --yes python=$PYTHON_VERSION pip
40+
source activate testenv
41+
conda install --yes numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION \
42+
scikit-learn=$SKLEARN_VERSION
43+
conda install --yes nose pytest pytest-cov
44+
# Install nose-timer via pip
45+
pip install nose-timer codecov
46+
47+
elif [[ "$DISTRIB" == "ubuntu" ]]; then
48+
# At the time of writing numpy 1.9.1 is included in the travis
49+
# virtualenv but we want to use the numpy installed through apt-get
50+
# install.
51+
deactivate
52+
# Create a new virtualenv using system site packages for python, numpy
53+
virtualenv --system-site-packages testvenv
54+
source testvenv/bin/activate
55+
pip install scikit-learn nose nose-timer pytest pytest-cov codecov
56+
57+
fi
58+
4059
python --version
4160
python -c "import numpy; print('numpy %s' % numpy.__version__)"
4261
python -c "import scipy; print('scipy %s' % scipy.__version__)"
4362

44-
cd $TRAVIS_BUILD_DIR
4563
python setup.py develop
64+
ccache --show-stats
65+
# Useful for debugging how ccache is used
66+
# cat $CCACHE_LOGFILE

circle.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@ dependencies:
2323
- sudo apt-get install build-essential python-dev python-setuptools
2424
# install numpy first as it is a compile time dependency for other packages
2525
- pip install --upgrade numpy
26-
- pip install --upgrade scipy matplotlib setuptools nose coverage pillow sphinx-gallery sphinx_rtd_theme sphinx==1.5.6
26+
- pip install --upgrade scipy matplotlib setuptools nose coverage pillow
27+
- pip install --upgrade scikit-learn numpydoc
28+
- pip install --upgrade sphinx-gallery sphinx_rtd_theme sphinx==1.5.6
2729
# Installing required packages for `make -C doc check command` to work.
2830
- sudo -E apt-get -yq update
2931
- sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install dvipng texlive-latex-base texlive-latex-extra
30-
- pip install --upgrade cython numpydoc
31-
- pip install --upgrade scikit-learn
32-
- pip install --upgrade seaborn
3332

3433
# The --user is needed to let sphinx see the source and the binaries
3534
# The pipefail is requested to propagate exit code

imblearn/combine/tests/test_smote_enn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from __future__ import print_function
77

88
import numpy as np
9-
from numpy.testing import (assert_allclose, assert_array_equal,
10-
assert_raises_regex)
9+
from sklearn.utils.testing import (assert_allclose, assert_array_equal,
10+
assert_raises_regex)
1111

1212
from imblearn.combine import SMOTEENN
1313
from imblearn.under_sampling import EditedNearestNeighbours

imblearn/combine/tests/test_smote_tomek.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from __future__ import print_function
77

88
import numpy as np
9-
from numpy.testing import (assert_allclose, assert_array_equal,
10-
assert_raises_regex)
9+
from sklearn.utils.testing import (assert_allclose, assert_array_equal,
10+
assert_raises_regex)
1111

1212
from imblearn.combine import SMOTETomek
1313
from imblearn.over_sampling import SMOTE

imblearn/datasets/tests/test_make_imbalance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
from collections import Counter
1010

1111
import numpy as np
12-
from sklearn.utils.testing import assert_true
13-
from numpy.testing import assert_equal, assert_raises_regex
12+
from sklearn.utils.testing import (assert_true, assert_equal,
13+
assert_raises_regex)
1414

1515
from imblearn.datasets import make_imbalance
1616

imblearn/datasets/tests/test_zenodo.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ def test_fetch():
5757
assert_equal(DATASET_SHAPE[k], X1.shape)
5858
assert_equal(X1.shape, X2.shape)
5959

60-
assert_allclose(X1.sum(), X2.sum())
61-
6260
y1, y2 = datasets1[k].target, datasets2[k].target
6361
assert_equal((X1.shape[0],), y1.shape)
6462
assert_equal((X1.shape[0],), y2.shape)

imblearn/ensemble/tests/test_balance_cascade.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from __future__ import print_function
77

88
import numpy as np
9-
from numpy.testing import (assert_array_equal, assert_raises,
10-
assert_raises_regex)
9+
from sklearn.utils.testing import (assert_array_equal, assert_raises,
10+
assert_raises_regex)
1111
from sklearn.ensemble import RandomForestClassifier
1212

1313
from imblearn.ensemble import BalanceCascade

imblearn/ensemble/tests/test_easy_ensemble.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from __future__ import print_function
77

88
import numpy as np
9-
from numpy.testing import assert_array_equal, assert_equal
9+
from sklearn.utils.testing import assert_array_equal, assert_equal
1010

1111
from imblearn.ensemble import EasyEnsemble
1212

imblearn/metrics/classification.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,6 @@ class is unrecognized by the classifier, G-mean resolves to zero. To
581581

582582
LOGGER.debug('The sensitivity and specificity are : %s - %s' %
583583
(sen, spe))
584-
585584
return np.sqrt(sen * spe)
586585
else:
587586
present_labels = unique_labels(y_true, y_pred)
@@ -628,7 +627,11 @@ class is unrecognized by the classifier, G-mean resolves to zero. To
628627
"recall")
629628
recall[recall == 0] = correction
630629

631-
return sp.stats.mstats.gmean(recall)
630+
gmean = sp.stats.gmean(recall)
631+
# old version of scipy return MaskedConstant instead of 0.0
632+
if isinstance(gmean, np.ma.core.MaskedConstant):
633+
return 0.0
634+
return gmean
632635

633636

634637
def make_index_balanced_accuracy(alpha=0.1, squared=True):

imblearn/metrics/tests/test_classification.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,17 @@
1010

1111
import numpy as np
1212

13-
from numpy.testing import (assert_allclose, assert_array_equal,
14-
assert_no_warnings, assert_equal,
15-
assert_raises)
16-
from sklearn.utils.testing import assert_warns_message, ignore_warnings
17-
1813
from sklearn import datasets
1914
from sklearn import svm
2015

2116
from sklearn.preprocessing import label_binarize
2217
from sklearn.utils.fixes import np_version
23-
from sklearn.utils.testing import assert_not_equal, assert_raise_message
2418
from sklearn.utils.validation import check_random_state
19+
from sklearn.utils.testing import (assert_allclose, assert_array_equal,
20+
assert_no_warnings, assert_equal,
21+
assert_raises, assert_warns_message,
22+
ignore_warnings, assert_not_equal,
23+
assert_raise_message)
2524
from sklearn.metrics import (accuracy_score, average_precision_score,
2625
brier_score_loss, cohen_kappa_score,
2726
jaccard_similarity_score, precision_score,
@@ -230,6 +229,7 @@ def test_geometric_mean_multiclass():
230229

231230
y_true = [0, 0, 0, 0]
232231
y_pred = [1, 1, 1, 1]
232+
print(geometric_mean_score(y_true, y_pred))
233233
assert_allclose(geometric_mean_score(y_true, y_pred), 0.0, rtol=R_TOL)
234234

235235
cor = 0.001

imblearn/metrics/tests/test_score_objects.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
# Christos Aridas
44
# License: MIT
55

6-
from numpy.testing import assert_allclose
7-
86
import sklearn
97

108
from sklearn.datasets import make_blobs
119
from sklearn.metrics import make_scorer
1210
from sklearn.svm import LinearSVC
11+
from sklearn.utils.testing import assert_allclose
1312

1413
from imblearn.metrics import (sensitivity_score, specificity_score,
1514
geometric_mean_score,

imblearn/over_sampling/tests/test_adasyn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from __future__ import print_function
77

88
import numpy as np
9-
from numpy.testing import (assert_allclose, assert_array_equal,
10-
assert_equal, assert_raises_regex)
9+
from sklearn.utils.testing import (assert_allclose, assert_array_equal,
10+
assert_equal, assert_raises_regex)
1111
from sklearn.neighbors import NearestNeighbors
1212

1313
from imblearn.over_sampling import ADASYN

imblearn/over_sampling/tests/test_random_over_sampler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from collections import Counter
99

1010
import numpy as np
11-
from numpy.testing import assert_array_equal, assert_equal
11+
from sklearn.utils.testing import assert_array_equal, assert_equal
1212

1313
from imblearn.over_sampling import RandomOverSampler
1414

imblearn/over_sampling/tests/test_smote.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from __future__ import print_function
77

88
import numpy as np
9-
from numpy.testing import (assert_allclose, assert_array_equal,
10-
assert_raises_regex)
9+
from sklearn.utils.testing import (assert_allclose, assert_array_equal,
10+
assert_raises_regex)
1111
from sklearn.neighbors import NearestNeighbors
1212
from sklearn.svm import SVC
1313

imblearn/under_sampling/prototype_generation/tests/test_cluster_centroids.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from collections import Counter
55

66
import numpy as np
7-
from numpy.testing import (assert_allclose, assert_array_equal,
8-
assert_equal, assert_raises_regex)
7+
from sklearn.utils.testing import (assert_allclose, assert_array_equal,
8+
assert_equal, assert_raises_regex)
99
from sklearn.cluster import KMeans
1010

1111
from imblearn.under_sampling import ClusterCentroids

imblearn/under_sampling/prototype_selection/tests/test_allknn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from __future__ import print_function
77

88
import numpy as np
9-
from numpy.testing import (assert_allclose, assert_array_equal,
10-
assert_raises)
9+
from sklearn.utils.testing import (assert_allclose, assert_array_equal,
10+
assert_raises)
1111
from sklearn.neighbors import NearestNeighbors
1212

1313
from imblearn.under_sampling import AllKNN

0 commit comments

Comments
 (0)