Skip to content

Commit

Permalink
CI Add more platform for testing (scikit-learn-contrib#309)
Browse files Browse the repository at this point in the history
[MRG] Add more platform for testing
  • Loading branch information
glemaitre authored Aug 2, 2017
1 parent dd941e7 commit f695fb7
Show file tree
Hide file tree
Showing 30 changed files with 150 additions and 103 deletions.
22 changes: 14 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
# make it explicit that we favor the new container-based travis workers
dist: trusty
sudo: false

language: python
python:
- 2.7

# Pre-install packages for the ubuntu distribution
cache:
apt: true
# We use three different cache directory
# to work around a Travis bug with multi-platform cache
directories:
- $HOME/.cache/pip
- $HOME/.cache/pip
- $HOME/download
addons:
apt:
packages:
- libatlas3gf-base
- libatlas-dev
- gfortran
- libgfortran3
- python-numpy
- python-scipy
env:
global:
# Directory where tests are run from
Expand All @@ -28,10 +27,17 @@ env:
- OPENBLAS_NUM_THREADS=4
matrix:
# This environment tests the using anaconda
# Ubuntu 14.04 environment
- DISTRIB="ubuntu"
# Latest release
- DISTRIB="conda" PYTHON_VERSION="2.7"
NUMPY_VERSION="1.11.2" SCIPY_VERSION="0.18.1" SKLEARN_VERSION="0.18.1"
NUMPY_VERSION="1.13.1" SCIPY_VERSION="0.19.1" SKLEARN_VERSION="0.18.2"
- DISTRIB="conda" PYTHON_VERSION="3.4"
NUMPY_VERSION="1.11.3" SCIPY_VERSION="0.18.1" SKLEARN_VERSION="0.18.1"
- DISTRIB="conda" PYTHON_VERSION="3.5"
NUMPY_VERSION="1.11.2" SCIPY_VERSION="0.18.1" SKLEARN_VERSION="0.18.1"
NUMPY_VERSION="1.13.1" SCIPY_VERSION="0.19.1" SKLEARN_VERSION="0.18.2"
- DISTRIB="conda" PYTHON_VERSION="3.6"
NUMPY_VERSION="1.13.1" SCIPY_VERSION="0.19.1" SKLEARN_VERSION="0.18.2"

install: source build_tools/travis/install.sh
script: bash build_tools/travis/test_script.sh
Expand Down
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ Installation
Dependencies
~~~~~~~~~~~~

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

* scipy(>=0.18.1)
* numpy(>=1.11.2)
* scipy(>=0.13.3)
* numpy(>=1.8.2)
* scikit-learn(>=0.18.1)

Additionally, to run the examples, you need matplotlib(>=2.0.0).
Expand Down
16 changes: 16 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,26 @@ environment:
PYTHON_VERSION: "2.7.x"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Miniconda-x64"
PYTHON_VERSION: "2.7.x"
PYTHON_ARCH: "32"

- PYTHON: "C:\\Miniconda3-x64"
PYTHON_VERSION: "3.4.x"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Miniconda3-x64"
PYTHON_VERSION: "3.5.x"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Miniconda3-x64"
PYTHON_VERSION: "3.6.x"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Miniconda3-x64"
PYTHON_VERSION: "3.6.x"
PYTHON_ARCH: "32"

install:
# Prepend miniconda installed Python to the PATH of this build
# Add Library/bin directory to fix issue
Expand Down
99 changes: 60 additions & 39 deletions build_tools/travis/install.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,45 +1,66 @@
# Deactivate the travis-provided virtual environment and setup a
# conda-based environment instead
deactivate

# Use the miniconda installer for faster download / install of conda
# itself
pushd .
cd
mkdir -p download
cd download
echo "Cached in $HOME/download :"
ls -l
echo
if [[ ! -f miniconda.sh ]]
then
wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh \
#!/bin/bash
# This script is meant to be called by the "install" step defined in
# .travis.yml. See http://docs.travis-ci.com/ for more details.
# The behavior of the script is controlled by environment variabled defined
# in the .travis.yml in the top level folder of the project.

# License: 3-clause BSD

# Travis clone pydicom/pydicom repository in to a local repository.

set -e

echo 'List files from cached directories'
echo 'pip:'
ls $HOME/.cache/pip

export CC=/usr/lib/ccache/gcc
export CXX=/usr/lib/ccache/g++
# Useful for debugging how ccache is used
# export CCACHE_LOGFILE=/tmp/ccache.log
# ~60M is used by .ccache when compiling from scratch at the time of writing
ccache --max-size 100M --show-stats

if [[ "$DISTRIB" == "conda" ]]; then
# Deactivate the travis-provided virtual environment and setup a
# conda-based environment instead
deactivate

# Install miniconda
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \
-O miniconda.sh
fi
chmod +x miniconda.sh && ./miniconda.sh -b
cd ..
export PATH=/home/travis/miniconda2/bin:$PATH
conda update --yes conda
popd

# Configure the conda environment and put it in the path using the
# provided versions
conda create -n testenv --yes python=$PYTHON_VERSION pip nose
numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION \
libgfortran nomkl
source activate testenv

# Install scikit-learn
conda install --yes scikit-learn=$SKLEARN_VERSION

# Install nose-timer via pip
pip install nose-timer coverage codecov

# Build imbalanced-learn in the install.sh script to collapse the verbose
# build output in the travis output when it succeeds.
MINICONDA_PATH=/home/travis/miniconda
chmod +x miniconda.sh && ./miniconda.sh -b -p $MINICONDA_PATH
export PATH=$MINICONDA_PATH/bin:$PATH
conda update --yes conda

# Configure the conda environment and put it in the path using the
# provided versions
conda create -n testenv --yes python=$PYTHON_VERSION pip
source activate testenv
conda install --yes numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION \
scikit-learn=$SKLEARN_VERSION
conda install --yes nose pytest pytest-cov
# Install nose-timer via pip
pip install nose-timer codecov

elif [[ "$DISTRIB" == "ubuntu" ]]; then
# At the time of writing numpy 1.9.1 is included in the travis
# virtualenv but we want to use the numpy installed through apt-get
# install.
deactivate
# Create a new virtualenv using system site packages for python, numpy
virtualenv --system-site-packages testvenv
source testvenv/bin/activate
pip install scikit-learn nose nose-timer pytest pytest-cov codecov

fi

python --version
python -c "import numpy; print('numpy %s' % numpy.__version__)"
python -c "import scipy; print('scipy %s' % scipy.__version__)"

cd $TRAVIS_BUILD_DIR
python setup.py develop
ccache --show-stats
# Useful for debugging how ccache is used
# cat $CCACHE_LOGFILE
7 changes: 3 additions & 4 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ dependencies:
- sudo apt-get install build-essential python-dev python-setuptools
# install numpy first as it is a compile time dependency for other packages
- pip install --upgrade numpy
- pip install --upgrade scipy matplotlib setuptools nose coverage pillow sphinx-gallery sphinx_rtd_theme sphinx==1.5.6
- pip install --upgrade scipy matplotlib setuptools nose coverage pillow
- pip install --upgrade scikit-learn numpydoc
- pip install --upgrade sphinx-gallery sphinx_rtd_theme sphinx==1.5.6
# Installing required packages for `make -C doc check command` to work.
- sudo -E apt-get -yq update
- sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install dvipng texlive-latex-base texlive-latex-extra
- pip install --upgrade cython numpydoc
- pip install --upgrade scikit-learn
- pip install --upgrade seaborn

# The --user is needed to let sphinx see the source and the binaries
# The pipefail is requested to propagate exit code
Expand Down
4 changes: 2 additions & 2 deletions imblearn/combine/tests/test_smote_enn.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from __future__ import print_function

import numpy as np
from numpy.testing import (assert_allclose, assert_array_equal,
assert_raises_regex)
from sklearn.utils.testing import (assert_allclose, assert_array_equal,
assert_raises_regex)

from imblearn.combine import SMOTEENN
from imblearn.under_sampling import EditedNearestNeighbours
Expand Down
4 changes: 2 additions & 2 deletions imblearn/combine/tests/test_smote_tomek.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from __future__ import print_function

import numpy as np
from numpy.testing import (assert_allclose, assert_array_equal,
assert_raises_regex)
from sklearn.utils.testing import (assert_allclose, assert_array_equal,
assert_raises_regex)

from imblearn.combine import SMOTETomek
from imblearn.over_sampling import SMOTE
Expand Down
4 changes: 2 additions & 2 deletions imblearn/datasets/tests/test_make_imbalance.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from collections import Counter

import numpy as np
from sklearn.utils.testing import assert_true
from numpy.testing import assert_equal, assert_raises_regex
from sklearn.utils.testing import (assert_true, assert_equal,
assert_raises_regex)

from imblearn.datasets import make_imbalance

Expand Down
2 changes: 0 additions & 2 deletions imblearn/datasets/tests/test_zenodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ def test_fetch():
assert_equal(DATASET_SHAPE[k], X1.shape)
assert_equal(X1.shape, X2.shape)

assert_allclose(X1.sum(), X2.sum())

y1, y2 = datasets1[k].target, datasets2[k].target
assert_equal((X1.shape[0],), y1.shape)
assert_equal((X1.shape[0],), y2.shape)
Expand Down
4 changes: 2 additions & 2 deletions imblearn/ensemble/tests/test_balance_cascade.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from __future__ import print_function

import numpy as np
from numpy.testing import (assert_array_equal, assert_raises,
assert_raises_regex)
from sklearn.utils.testing import (assert_array_equal, assert_raises,
assert_raises_regex)
from sklearn.ensemble import RandomForestClassifier

from imblearn.ensemble import BalanceCascade
Expand Down
2 changes: 1 addition & 1 deletion imblearn/ensemble/tests/test_easy_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from __future__ import print_function

import numpy as np
from numpy.testing import assert_array_equal, assert_equal
from sklearn.utils.testing import assert_array_equal, assert_equal

from imblearn.ensemble import EasyEnsemble

Expand Down
7 changes: 5 additions & 2 deletions imblearn/metrics/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,6 @@ class is unrecognized by the classifier, G-mean resolves to zero. To

LOGGER.debug('The sensitivity and specificity are : %s - %s' %
(sen, spe))

return np.sqrt(sen * spe)
else:
present_labels = unique_labels(y_true, y_pred)
Expand Down Expand Up @@ -628,7 +627,11 @@ class is unrecognized by the classifier, G-mean resolves to zero. To
"recall")
recall[recall == 0] = correction

return sp.stats.mstats.gmean(recall)
gmean = sp.stats.gmean(recall)
# old version of scipy return MaskedConstant instead of 0.0
if isinstance(gmean, np.ma.core.MaskedConstant):
return 0.0
return gmean


def make_index_balanced_accuracy(alpha=0.1, squared=True):
Expand Down
12 changes: 6 additions & 6 deletions imblearn/metrics/tests/test_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@

import numpy as np

from numpy.testing import (assert_allclose, assert_array_equal,
assert_no_warnings, assert_equal,
assert_raises)
from sklearn.utils.testing import assert_warns_message, ignore_warnings

from sklearn import datasets
from sklearn import svm

from sklearn.preprocessing import label_binarize
from sklearn.utils.fixes import np_version
from sklearn.utils.testing import assert_not_equal, assert_raise_message
from sklearn.utils.validation import check_random_state
from sklearn.utils.testing import (assert_allclose, assert_array_equal,
assert_no_warnings, assert_equal,
assert_raises, assert_warns_message,
ignore_warnings, assert_not_equal,
assert_raise_message)
from sklearn.metrics import (accuracy_score, average_precision_score,
brier_score_loss, cohen_kappa_score,
jaccard_similarity_score, precision_score,
Expand Down Expand Up @@ -230,6 +229,7 @@ def test_geometric_mean_multiclass():

y_true = [0, 0, 0, 0]
y_pred = [1, 1, 1, 1]
print(geometric_mean_score(y_true, y_pred))
assert_allclose(geometric_mean_score(y_true, y_pred), 0.0, rtol=R_TOL)

cor = 0.001
Expand Down
3 changes: 1 addition & 2 deletions imblearn/metrics/tests/test_score_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
# Christos Aridas
# License: MIT

from numpy.testing import assert_allclose

import sklearn

from sklearn.datasets import make_blobs
from sklearn.metrics import make_scorer
from sklearn.svm import LinearSVC
from sklearn.utils.testing import assert_allclose

from imblearn.metrics import (sensitivity_score, specificity_score,
geometric_mean_score,
Expand Down
4 changes: 2 additions & 2 deletions imblearn/over_sampling/tests/test_adasyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from __future__ import print_function

import numpy as np
from numpy.testing import (assert_allclose, assert_array_equal,
assert_equal, assert_raises_regex)
from sklearn.utils.testing import (assert_allclose, assert_array_equal,
assert_equal, assert_raises_regex)
from sklearn.neighbors import NearestNeighbors

from imblearn.over_sampling import ADASYN
Expand Down
2 changes: 1 addition & 1 deletion imblearn/over_sampling/tests/test_random_over_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from collections import Counter

import numpy as np
from numpy.testing import assert_array_equal, assert_equal
from sklearn.utils.testing import assert_array_equal, assert_equal

from imblearn.over_sampling import RandomOverSampler

Expand Down
4 changes: 2 additions & 2 deletions imblearn/over_sampling/tests/test_smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from __future__ import print_function

import numpy as np
from numpy.testing import (assert_allclose, assert_array_equal,
assert_raises_regex)
from sklearn.utils.testing import (assert_allclose, assert_array_equal,
assert_raises_regex)
from sklearn.neighbors import NearestNeighbors
from sklearn.svm import SVC

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from collections import Counter

import numpy as np
from numpy.testing import (assert_allclose, assert_array_equal,
assert_equal, assert_raises_regex)
from sklearn.utils.testing import (assert_allclose, assert_array_equal,
assert_equal, assert_raises_regex)
from sklearn.cluster import KMeans

from imblearn.under_sampling import ClusterCentroids
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from __future__ import print_function

import numpy as np
from numpy.testing import (assert_allclose, assert_array_equal,
assert_raises)
from sklearn.utils.testing import (assert_allclose, assert_array_equal,
assert_raises)
from sklearn.neighbors import NearestNeighbors

from imblearn.under_sampling import AllKNN
Expand Down
Loading

0 comments on commit f695fb7

Please sign in to comment.