Skip to content

Commit 7adc1b1

Browse files
authored
[MRG] Cleanup minimal build and add separate build for pep8 (#210)
* cleanup requiorement minimal * add pep8 build * cleanup sklearn * skip test if no sklearn * debug build yaml * comment error out in test (test sklearn) * maybe small stuff for better robustness : copy the sub-array * bump verison minimal build * update version strict requireent * update version strict requirement last change
1 parent 55164e9 commit 7adc1b1

File tree

6 files changed

+42
-21
lines changed

6 files changed

+42
-21
lines changed

.github/requirements_strict.txt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
numpy==1.16.*
2-
scipy==1.0.*
3-
cython==0.23.*
4-
matplotlib
5-
cvxopt
6-
scikit-learn
1+
numpy
2+
scipy>=1.3
3+
cython
74
pytest

.github/workflows/build_tests.yml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,7 @@ jobs:
3030
run: |
3131
python -m pip install --upgrade pip
3232
pip install -r requirements.txt
33-
pip install flake8 pytest "pytest-cov<2.6" codecov
34-
pip install -U "sklearn"
35-
- name: Lint with flake8
36-
run: |
37-
# stop the build if there are Python syntax errors or undefined names
38-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
39-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
40-
flake8 examples/ ot/ test/ --count --max-line-length=127 --statistics
33+
pip install pytest "pytest-cov<2.6" codecov
4134
- name: Install POT
4235
run: |
4336
pip install -e .
@@ -48,14 +41,37 @@ jobs:
4841
run: |
4942
codecov
5043
44+
pep8:
45+
runs-on: ubuntu-latest
46+
strategy:
47+
max-parallel: 4
48+
matrix:
49+
python-version: [3.8]
50+
51+
steps:
52+
- uses: actions/checkout@v1
53+
- name: Set up Python ${{ matrix.python-version }}
54+
uses: actions/setup-python@v1
55+
with:
56+
python-version: ${{ matrix.python-version }}
57+
- name: Install dependencies
58+
run: |
59+
python -m pip install --upgrade pip
60+
pip install flake8
61+
- name: Lint with flake8
62+
run: |
63+
# stop the build if there are Python syntax errors or undefined names
64+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
65+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
66+
flake8 examples/ ot/ test/ --count --max-line-length=127 --statistics
5167
5268
linux-minimal-deps:
5369

5470
runs-on: ubuntu-latest
5571
strategy:
5672
max-parallel: 4
5773
matrix:
58-
python-version: [3.6]
74+
python-version: [3.8]
5975

6076
steps:
6177
- uses: actions/checkout@v1
@@ -68,7 +84,6 @@ jobs:
6884
python -m pip install --upgrade pip
6985
pip install -r .github/requirements_strict.txt
7086
pip install pytest
71-
pip install -U "sklearn"
7287
- name: Install POT
7388
run: |
7489
pip install -e .
@@ -95,7 +110,6 @@ jobs:
95110
python -m pip install --upgrade pip
96111
pip install -r requirements.txt
97112
pip install pytest "pytest-cov<2.6"
98-
pip install -U "sklearn"
99113
- name: Install POT
100114
run: |
101115
pip install -e .
@@ -122,7 +136,6 @@ jobs:
122136
python -m pip install --upgrade pip
123137
pip install -r requirements.txt
124138
pip install pytest "pytest-cov<2.6"
125-
pip install -U "sklearn"
126139
- name: Install POT
127140
run: |
128141
pip install -e .

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ var/
4040
*.manifest
4141
*.spec
4242

43+
# env
44+
pythonenv3.8/
45+
4346
# Installer logs
4447
pip-log.txt
4548
pip-delete-this-directory.txt

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ pep8 :
4545
flake8 examples/ ot/ test/
4646

4747
test : FORCE pep8
48-
$(PYTHON) -m pytest -v test/ --doctest-modules --ignore ot/gpu/ --cov=ot --cov-report html:cov_html
48+
$(PYTHON) -m pytest -v test/ --doctest-modules --ignore ot/gpu/
4949

5050
pytest : FORCE
51-
$(PYTHON) -m pytest -v test/ --doctest-modules --ignore ot/gpu/ --cov=ot
51+
$(PYTHON) -m pytest -v test/ --doctest-modules --ignore ot/gpu/
5252

5353
release :
5454
twine upload dist/*

ot/lp/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def f(b):
426426
nb = b.shape[1]
427427

428428
if processes > 1:
429-
res = parmap(f, [b[:, i] for i in range(nb)], processes)
429+
res = parmap(f, [b[:, i].copy() for i in range(nb)], processes)
430430
else:
431431
res = list(map(f, [b[:, i].copy() for i in range(nb)]))
432432

test/test_da.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@
66

77
import numpy as np
88
from numpy.testing import assert_allclose, assert_equal
9+
import pytest
910

1011
import ot
1112
from ot.datasets import make_data_classif
1213
from ot.utils import unif
1314

15+
try: # test if cudamat installed
16+
import sklearn # noqa: F401
17+
nosklearn = False
18+
except ImportError:
19+
nosklearn = True
20+
1421

1522
def test_sinkhorn_lpl1_transport_class():
1623
"""test_sinkhorn_transport
@@ -691,6 +698,7 @@ def test_jcpot_barycenter():
691698
np.testing.assert_allclose(prop, [1 - pt, pt], rtol=1e-3, atol=1e-3)
692699

693700

701+
@pytest.mark.skipif(nosklearn, reason="No sklearn available")
694702
def test_emd_laplace_class():
695703
"""test_emd_laplace_transport
696704
"""

0 commit comments

Comments
 (0)