From 6caf3b4809993826320a662d9f3d86be61ab3ad7 Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Fri, 15 Nov 2019 09:28:52 +0100 Subject: Create pythonpackage.yml --- .github/workflows/pythonpackage.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/pythonpackage.yml (limited to '.github/workflows') diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml new file mode 100644 index 0000000..bb94926 --- /dev/null +++ b/.github/workflows/pythonpackage.yml @@ -0,0 +1,35 @@ +name: Test Package + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [2.7, 3.5, 3.6, 3.7] + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: Lint with flake8 + run: | + pip install flake8 + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pip install pytest "pytest-cov<2.6" + pip install . + python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot -- cgit v1.2.3 From 81a32a35a4b7ff10473ea9cc465af2d5c9337918 Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Fri, 15 Nov 2019 09:34:49 +0100 Subject: correct tests --- .github/workflows/pythonpackage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index bb94926..ec8f186 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -27,9 +27,9 @@ jobs: # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest run: | pip install pytest "pytest-cov<2.6" - pip install . + python setup.py develop python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot -- cgit v1.2.3 From 3635fc46d6fc55e6fa30b33ad07fe092dfd23241 Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Fri, 15 Nov 2019 09:38:59 +0100 Subject: Remove github action tests (PR is coming) --- .github/workflows/pythonpackage.yml | 5 ----- 1 file changed, 5 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index ec8f186..cb3baf8 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -28,8 +28,3 @@ jobs: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pip install pytest "pytest-cov<2.6" - python setup.py develop - python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot -- cgit v1.2.3 From f141b7ecec8f69db29fb3dcf1efd1d00d96db87d Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Tue, 21 Apr 2020 10:53:59 +0200 Subject: add artifact redirect --- .github/workflows/main.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/workflows/main.yml (limited to '.github/workflows') diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..ca10c8c --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,12 @@ +on: [status] +jobs: + circleci_artifacts_redirector_job: + runs-on: ubuntu-latest + name: Run CircleCI artifacts redirector + steps: + - name: GitHub Action step + uses: larsoner/circleci-artifacts-redirector-action@master + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + artifact-path: 0/docs/build/html/index.html + circleci-jobs: build_doc -- cgit v1.2.3 From 8c6a976c9d1225e469e22f7ef1c700eaf1e08dd7 Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Tue, 21 Apr 2020 11:00:24 +0200 Subject: try codecov setup --- .github/workflows/main.yml | 2 +- .travis.yml | 5 ++++- codecov.yml | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 codecov.yml (limited to '.github/workflows') diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ca10c8c..1a8a759 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,4 +9,4 @@ jobs: with: repo-token: ${{ secrets.GITHUB_TOKEN }} artifact-path: 0/docs/build/html/index.html - circleci-jobs: build_doc + circleci-jobs: build_docs diff --git a/.travis.yml b/.travis.yml index b9cc88f..3f63867 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,7 @@ before_install: install: - pip install -r requirements.txt - pip install -U "numpy>=1.14" scipy # for numpy array formatting in doctests - - pip install flake8 pytest "pytest-cov<2.6" + - pip install flake8 pytest "pytest-cov<2.6" codecov - pip install -U "sklearn" - pip install . # command to run tests + check syntax style @@ -45,3 +45,6 @@ script: - flake8 examples/ ot/ test/ - python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot # - py.test ot test +after_script: + # Need to run from source dir to execute "git" commands + - codecov; diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..1e7b888 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,14 @@ +coverage: + precision: 2 + round: down + range: "70...100" + status: + project: + default: + target: auto + threshold: 0.01 + patch: false + changes: false +comment: + layout: "header, diff, sunburst, uncovered" + behavior: default -- cgit v1.2.3 From 555f8426a8cb66ae5255885ce555037dc8c72c53 Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Tue, 21 Apr 2020 11:11:19 +0200 Subject: add codecov button --- .github/workflows/main.yml | 1 - README.md | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1a8a759..6b52555 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,6 +7,5 @@ jobs: - name: GitHub Action step uses: larsoner/circleci-artifacts-redirector-action@master with: - repo-token: ${{ secrets.GITHUB_TOKEN }} artifact-path: 0/docs/build/html/index.html circleci-jobs: build_docs diff --git a/README.md b/README.md index 931a252..64630e6 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![PyPI version](https://badge.fury.io/py/POT.svg)](https://badge.fury.io/py/POT) [![Anaconda Cloud](https://anaconda.org/conda-forge/pot/badges/version.svg)](https://anaconda.org/conda-forge/pot) [![Build Status](https://travis-ci.org/PythonOT/POT.svg?branch=master)](https://travis-ci.org/PythonOT/POT) +[![Codecov Status](https://codecov.io/gh/PythonOT/POT/branch/master/graph/badge.svg)](https://codecov.io/gh/PythonOT/POT) [![Documentation Status](https://readthedocs.org/projects/pot/badge/?version=latest)](http://pot.readthedocs.io/en/latest/?badge=latest) [![Downloads](https://pepy.tech/badge/pot)](https://pepy.tech/project/pot) [![Anaconda downloads](https://anaconda.org/conda-forge/pot/badges/downloads.svg)](https://anaconda.org/conda-forge/pot) -- cgit v1.2.3 From d3ebb36fc4a3614c5640d731ea793c0afd400e4e Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Tue, 21 Apr 2020 11:23:34 +0200 Subject: run gh actions all the time --- .github/workflows/main.yml | 11 ++++++++++- .github/workflows/pythonpackage.yml | 10 +++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6b52555..46f278a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,13 @@ -on: [status] +on: + push: + branches: + - '**' + create: + branches: + - 'master' + tags: + - '**' + jobs: circleci_artifacts_redirector_job: runs-on: ubuntu-latest diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index cb3baf8..d728edd 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -1,6 +1,14 @@ name: Test Package -on: [push] +on: + push: + branches: + - '**' + create: + branches: + - 'master' + tags: + - '**' jobs: build: -- cgit v1.2.3 From 624fd44c729a3b761d09a01b71338c0332b6b9fe Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Tue, 21 Apr 2020 11:24:42 +0200 Subject: fix --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) (limited to '.github/workflows') diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 46f278a..07686d9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,5 +16,6 @@ jobs: - name: GitHub Action step uses: larsoner/circleci-artifacts-redirector-action@master with: + repo-token: ${{ secrets.GITHUB_TOKEN }} artifact-path: 0/docs/build/html/index.html circleci-jobs: build_docs -- cgit v1.2.3 From 5c88642a27e6c330a5c795898c0de7f3b4c0cd8d Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Tue, 21 Apr 2020 12:00:03 +0200 Subject: fix? --- .circleci/config.yml | 3 ++- .github/workflows/main.yml | 13 ++----------- 2 files changed, 4 insertions(+), 12 deletions(-) (limited to '.github/workflows') diff --git a/.circleci/config.yml b/.circleci/config.yml index 455b700..ea5981e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -134,4 +134,5 @@ workflows: filters: branches: only: - - master + # - master + - doc_ci_build diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 07686d9..7153fe6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,13 +1,4 @@ -on: - push: - branches: - - '**' - create: - branches: - - 'master' - tags: - - '**' - +on: [status] jobs: circleci_artifacts_redirector_job: runs-on: ubuntu-latest @@ -17,5 +8,5 @@ jobs: uses: larsoner/circleci-artifacts-redirector-action@master with: repo-token: ${{ secrets.GITHUB_TOKEN }} - artifact-path: 0/docs/build/html/index.html + artifact-path: 0/dev/index.html circleci-jobs: build_docs -- cgit v1.2.3 From 8497cd523085ea69d949a0de67db252b36a81d8e Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Tue, 21 Apr 2020 12:03:44 +0200 Subject: run tests in GH actions --- .github/workflows/pythonpackage.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index d728edd..d60acd2 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -29,10 +29,18 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt + pip install flake8 pytest "pytest-cov<2.6" codecov + pip install -U "sklearn" - name: Lint with flake8 run: | - pip install flake8 # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Run tests + run: | + pip install . + python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot + - name: Upload codecov + run: | + codecov -- cgit v1.2.3 From bdf608bfb417a15545d581aa2d57160401aacb6e Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Tue, 21 Apr 2020 12:09:53 +0200 Subject: fix? --- .github/workflows/pythonpackage.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index d60acd2..c4b0165 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -17,7 +17,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [2.7, 3.5, 3.6, 3.7] + python-version: [3.5, 3.6, 3.7, 3.8] steps: - uses: actions/checkout@v1 @@ -37,9 +37,11 @@ jobs: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Install POT + run: | + pip install -e . - name: Run tests run: | - pip install . python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot - name: Upload codecov run: | -- cgit v1.2.3 From 0b2d808aaebb1cab60a272ea7901d5f77df43a9f Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Tue, 21 Apr 2020 17:20:46 +0200 Subject: Windows CI (#148) * add Windows build on GH actions --- .github/workflows/pythonpackage.yml | 55 ++++++++++++++++++++++++++++++++++++- README.md | 1 + 2 files changed, 55 insertions(+), 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index c4b0165..19527c3 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -11,7 +11,7 @@ on: - '**' jobs: - build: + linux: runs-on: ubuntu-latest strategy: @@ -46,3 +46,56 @@ jobs: - name: Upload codecov run: | codecov + + # macos: + # runs-on: macOS-latest + # strategy: + # max-parallel: 4 + # matrix: + # python-version: [3.7] + + # steps: + # - uses: actions/checkout@v1 + # - name: Set up Python ${{ matrix.python-version }} + # uses: actions/setup-python@v1 + # with: + # python-version: ${{ matrix.python-version }} + # - name: Install dependencies + # run: | + # python -m pip install --upgrade pip + # pip install -r requirements.txt + # pip install pytest "pytest-cov<2.6" + # pip install -U "sklearn" + # - name: Install POT + # run: | + # pip install -e . + # - name: Run tests + # run: | + # python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot + + + windows: + runs-on: windows-2019 + strategy: + max-parallel: 4 + matrix: + python-version: [3.7] + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pytest "pytest-cov<2.6" + pip install -U "sklearn" + - name: Install POT + run: | + pip install -e . + - name: Run tests + run: | + python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot diff --git a/README.md b/README.md index 64630e6..65193ff 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![PyPI version](https://badge.fury.io/py/POT.svg)](https://badge.fury.io/py/POT) [![Anaconda Cloud](https://anaconda.org/conda-forge/pot/badges/version.svg)](https://anaconda.org/conda-forge/pot) [![Build Status](https://travis-ci.org/PythonOT/POT.svg?branch=master)](https://travis-ci.org/PythonOT/POT) +[![Build Status](https://github.com/PythonOT/POT/workflows/Linux%7CWin%7CMacOS/badge.svg)](https://github.com/PythonOT/POT/actions) [![Codecov Status](https://codecov.io/gh/PythonOT/POT/branch/master/graph/badge.svg)](https://codecov.io/gh/PythonOT/POT) [![Documentation Status](https://readthedocs.org/projects/pot/badge/?version=latest)](http://pot.readthedocs.io/en/latest/?badge=latest) [![Downloads](https://pepy.tech/badge/pot)](https://pepy.tech/project/pot) -- cgit v1.2.3 From f9638166521a1160838fae75e2a2e318d645460e Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Tue, 21 Apr 2020 17:40:32 +0200 Subject: rm travis --- .github/workflows/pythonpackage.yml | 8 +++--- .travis.yml | 50 ------------------------------------- .travis/before_install.sh | 15 ----------- README.md | 1 - 4 files changed, 3 insertions(+), 71 deletions(-) delete mode 100644 .travis.yml delete mode 100755 .travis/before_install.sh (limited to '.github/workflows') diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 19527c3..755937a 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -3,12 +3,10 @@ name: Test Package on: push: branches: - - '**' - create: + - master + pull_request: branches: - - 'master' - tags: - - '**' + - master jobs: linux: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3f63867..0000000 --- a/.travis.yml +++ /dev/null @@ -1,50 +0,0 @@ -dist: xenial # required for Python >= 3.7 -language: python -matrix: - # allow_failures: - # - os: osx - # - os: windows - include: - - os: linux - sudo: required - python: 3.5 - - os: linux - sudo: required - python: 3.6 - - os: linux - sudo: required - python: 3.7 - - os: linux - sudo: required - python: 3.8 - # - os: osx - # sudo: required - # language: generic - # - name: "Python 3.7.3 on Windows" - # os: windows # Windows 10.0.17134 N/A Build 17134 - # language: shell # 'language: python' is an error on Travis CI Windows - # before_install: choco install python - # env: PATH=/c/Python37:/c/Python37/Scripts:$PATH -# before_script: # configure a headless display to test plot generation -# - "export DISPLAY=:99.0" -# - sleep 3 # give xvfb some time to start -before_install: - - ./.travis/before_install.sh -# command to install dependencies -install: - - pip install -r requirements.txt - - pip install -U "numpy>=1.14" scipy # for numpy array formatting in doctests - - pip install flake8 pytest "pytest-cov<2.6" codecov - - pip install -U "sklearn" - - pip install . -# command to run tests + check syntax style -services: - - xvfb -script: - - python setup.py develop - - flake8 examples/ ot/ test/ - - python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot - # - py.test ot test -after_script: - # Need to run from source dir to execute "git" commands - - codecov; diff --git a/.travis/before_install.sh b/.travis/before_install.sh deleted file mode 100755 index 0ae6249..0000000 --- a/.travis/before_install.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -if [[ $TRAVIS_OS_NAME == 'osx' ]]; then - - # Install some custom requirements on OS X - # e.g. brew install pyenv-virtualenv - #brew update - #brew install python - sudo easy_install -U pip - -else - # Install some custom requirements on Linux - sudo apt-get update -q - sudo apt-get install libblas-dev liblapack-dev libatlas-base-dev -fi diff --git a/README.md b/README.md index 65193ff..ca8481c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ [![PyPI version](https://badge.fury.io/py/POT.svg)](https://badge.fury.io/py/POT) [![Anaconda Cloud](https://anaconda.org/conda-forge/pot/badges/version.svg)](https://anaconda.org/conda-forge/pot) -[![Build Status](https://travis-ci.org/PythonOT/POT.svg?branch=master)](https://travis-ci.org/PythonOT/POT) [![Build Status](https://github.com/PythonOT/POT/workflows/Linux%7CWin%7CMacOS/badge.svg)](https://github.com/PythonOT/POT/actions) [![Codecov Status](https://codecov.io/gh/PythonOT/POT/branch/master/graph/badge.svg)](https://codecov.io/gh/PythonOT/POT) [![Documentation Status](https://readthedocs.org/projects/pot/badge/?version=latest)](http://pot.readthedocs.io/en/latest/?badge=latest) -- cgit v1.2.3 From 72dc1d57bb0b94603b7d08bd5830f8391dd59502 Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Tue, 21 Apr 2020 23:07:16 +0200 Subject: fix GH Action badge in readme (#153) --- .github/workflows/pythonpackage.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 19527c3..af6efb7 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -1,4 +1,4 @@ -name: Test Package +name: build on: push: diff --git a/README.md b/README.md index 40f43e0..1cc39e6 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![PyPI version](https://badge.fury.io/py/POT.svg)](https://badge.fury.io/py/POT) [![Anaconda Cloud](https://anaconda.org/conda-forge/pot/badges/version.svg)](https://anaconda.org/conda-forge/pot) [![Build Status](https://travis-ci.org/PythonOT/POT.svg?branch=master)](https://travis-ci.org/PythonOT/POT) -[![Build Status](https://github.com/PythonOT/POT/workflows/Linux%7CWin%7CMacOS/badge.svg)](https://github.com/PythonOT/POT/actions) +[![Build Status](https://github.com/PythonOT/POT/workflows/build/badge.svg)](https://github.com/PythonOT/POT/actions) [![Codecov Status](https://codecov.io/gh/PythonOT/POT/branch/master/graph/badge.svg)](https://codecov.io/gh/PythonOT/POT) [![Downloads](https://pepy.tech/badge/pot)](https://pepy.tech/project/pot) [![Anaconda downloads](https://anaconda.org/conda-forge/pot/badges/downloads.svg)](https://anaconda.org/conda-forge/pot) -- cgit v1.2.3 From 2a8c86cdad1948ad3c907ad8de2ec14d0d689a2e Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Wed, 22 Apr 2020 11:05:45 +0200 Subject: add flake8 fail to github actions --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index af6efb7..394f453 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -36,7 +36,7 @@ jobs: # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + flake8 examples/ ot/ test/ --count --max-line-length=127 --statistics - name: Install POT run: | pip install -e . -- cgit v1.2.3 From 249d46c2aa29e7f975e3acbe8c9ae29a1dfc5490 Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Wed, 22 Apr 2020 11:17:08 +0200 Subject: rename circleci redicrector action --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) (limited to '.github/workflows') diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7153fe6..ae7bfca 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,3 +1,4 @@ +name: circleci-redirector on: [status] jobs: circleci_artifacts_redirector_job: -- cgit v1.2.3 From c60cb3bcfd3ff67113a8d8a84230ffd263b72c6e Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Wed, 22 Apr 2020 15:38:39 +0200 Subject: add wheel build action --- .github/workflows/build_wheels.yml | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/build_wheels.yml (limited to '.github/workflows') diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml new file mode 100644 index 0000000..5ade5d7 --- /dev/null +++ b/.github/workflows/build_wheels.yml @@ -0,0 +1,41 @@ +name: Build dist and wheels + +on: + push: + branches: + - 'build_wheels' + + +jobs: + build_linux: + + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.5, 3.6, 3.7, 3.8] + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Install cibuildwheel + run: | + python -m pip install cibuildwheel==1.3.0 + + - name: Build wheel + run: | + python -m cibuildwheel --output-dir wheelhouse + + - uses: actions/upload-artifact@v1 + with: + name: wheels + path: ./wheelhouse \ No newline at end of file -- cgit v1.2.3 From 4aa020055a684ec8cd2360ecf47bd85f94e63e9e Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Wed, 22 Apr 2020 15:42:56 +0200 Subject: force install cython --- .github/workflows/build_wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 5ade5d7..d92c7c5 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -26,7 +26,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt - + pip install -U "cython" - name: Install cibuildwheel run: | python -m pip install cibuildwheel==1.3.0 -- cgit v1.2.3 From de5ff644d282660f34a8fad051879eca7cdc87a3 Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Wed, 22 Apr 2020 15:47:56 +0200 Subject: propoer ciwb before build --- .github/workflows/build_wheels.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index d92c7c5..9938698 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -13,7 +13,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [3.5, 3.6, 3.7, 3.8] + python-version: [3.8] steps: - uses: actions/checkout@v1 @@ -32,6 +32,8 @@ jobs: python -m pip install cibuildwheel==1.3.0 - name: Build wheel + env: + CIBW_BEFORE_BUILD: "pip install numpy cython" run: | python -m cibuildwheel --output-dir wheelhouse -- cgit v1.2.3 From b8c36c9a4f807b4743c296e84f3f0896a778619e Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Wed, 22 Apr 2020 16:15:44 +0200 Subject: test build wheels windows --- .github/workflows/build_wheels.yml | 39 ++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 9938698..ed8bd3d 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -10,17 +10,44 @@ jobs: build_linux: runs-on: ubuntu-latest - strategy: - max-parallel: 4 - matrix: - python-version: [3.8] steps: - uses: actions/checkout@v1 - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python 3.8 uses: actions/setup-python@v1 with: - python-version: ${{ matrix.python-version }} + python-version: 3.8 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install -U "cython" + - name: Install cibuildwheel + run: | + python -m pip install cibuildwheel==1.3.0 + + - name: Build wheel + env: + CIBW_BEFORE_BUILD: "pip install numpy cython" + run: | + python -m cibuildwheel --output-dir wheelhouse + + - uses: actions/upload-artifact@v1 + with: + name: wheels + path: ./wheelhouse + + build_windows: + + runs-on: windows-2019 + + steps: + - uses: actions/checkout@v1 + - name: Set up Python 3.8 + uses: actions/setup-python@v1 + with: + python-version: 3.8 - name: Install dependencies run: | -- cgit v1.2.3 From d20ce8c4e6ef723bec0ee4f06b285dff8da8c6f7 Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Wed, 22 Apr 2020 16:21:04 +0200 Subject: debug build wheels windows --- .github/workflows/build_wheels.yml | 44 ++++++++++---------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index ed8bd3d..4874d84 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -7,9 +7,12 @@ on: jobs: - build_linux: - - runs-on: ubuntu-latest + build_wheels: + name: Build wheel on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-18.04, windows-latest, macos-latest] steps: - uses: actions/checkout@v1 @@ -23,40 +26,15 @@ jobs: python -m pip install --upgrade pip pip install -r requirements.txt pip install -U "cython" + - name: Install cibuildwheel run: | python -m pip install cibuildwheel==1.3.0 - - name: Build wheel - env: - CIBW_BEFORE_BUILD: "pip install numpy cython" - run: | - python -m cibuildwheel --output-dir wheelhouse - - - uses: actions/upload-artifact@v1 - with: - name: wheels - path: ./wheelhouse - - build_windows: - - runs-on: windows-2019 - - steps: - - uses: actions/checkout@v1 - - name: Set up Python 3.8 - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - - name: Install dependencies + - name: Install Visual C++ for Python 2.7 + if: startsWith(matrix.os, 'windows') run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install -U "cython" - - name: Install cibuildwheel - run: | - python -m pip install cibuildwheel==1.3.0 + choco install vcpython27 -f -y - name: Build wheel env: @@ -67,4 +45,4 @@ jobs: - uses: actions/upload-artifact@v1 with: name: wheels - path: ./wheelhouse \ No newline at end of file + path: ./wheelhouse -- cgit v1.2.3 From 57153c8c6a30d044690b46f77ea5c584f5e5d088 Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Wed, 22 Apr 2020 16:34:26 +0200 Subject: remove macosx --- .github/workflows/build_wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 4874d84..9f671bf 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -12,7 +12,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-18.04, windows-latest, macos-latest] + os: [ubuntu-18.04, windows-latest] steps: - uses: actions/checkout@v1 -- cgit v1.2.3 From 6bcd9e6b988c2856b910a9c87663e4a0cbd1ea19 Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Wed, 22 Apr 2020 20:09:14 +0200 Subject: stick to linux wheels for current release --- .github/workflows/build_wheels.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 9f671bf..b11cfaa 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -8,11 +8,12 @@ on: jobs: build_wheels: - name: Build wheel on ${{ matrix.os }} + name: ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-18.04, windows-latest] + os: [ubuntu-18.04] + # macosx-latest, windows-latest steps: - uses: actions/checkout@v1 -- cgit v1.2.3 From ebf8fe9d1c3ff7885c00f695812964faf119486c Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Thu, 23 Apr 2020 09:30:24 +0200 Subject: set action to release event --- .github/workflows/build_wheels.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index b11cfaa..7c13c33 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -1,10 +1,7 @@ name: Build dist and wheels on: - push: - branches: - - 'build_wheels' - + release: jobs: build_wheels: -- cgit v1.2.3 From 73db416784c400eccb5cdea0b3a00ac4bd68c595 Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Thu, 23 Apr 2020 10:57:26 +0200 Subject: revert changes on GH yml --- .github/workflows/pythonpackage.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 755937a..5b1fa0e 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -1,12 +1,14 @@ -name: Test Package +name: build on: push: branches: - - master - pull_request: + - '**' + create: branches: - - master + - 'master' + tags: + - '**' jobs: linux: @@ -34,7 +36,7 @@ jobs: # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + flake8 examples/ ot/ test/ --count --max-line-length=127 --statistics - name: Install POT run: | pip install -e . @@ -97,3 +99,4 @@ jobs: - name: Run tests run: | python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot +=ot -- cgit v1.2.3 From fc8d9d9714e15280b5cfc27ac1190cda3b57966f Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Thu, 23 Apr 2020 10:58:54 +0200 Subject: oups --- .github/workflows/pythonpackage.yml | 1 - 1 file changed, 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 5b1fa0e..c916647 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -99,4 +99,3 @@ jobs: - name: Run tests run: | python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot -=ot -- cgit v1.2.3 From ef12867f1425ee86b3cfddef4287b52d46114e83 Mon Sep 17 00:00:00 2001 From: Nicolas Courty Date: Thu, 23 Apr 2020 13:03:28 +0200 Subject: [WIP] Issue with sparse emd and adding tests on macos (#158) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * First commit-warning removal * remove dense feature * pep8 * pep8 * EMD.h * pep8 again * tic toc tolerance Co-authored-by: Rémi Flamary --- .github/workflows/pythonpackage.yml | 48 +++++----- ot/lp/EMD.h | 3 - ot/lp/EMD_wrapper.cpp | 182 ------------------------------------ ot/lp/__init__.py | 45 +++------ ot/lp/emd_wrap.pyx | 38 ++------ ot/lp/network_simplex_simple.h | 5 +- test/test_ot.py | 26 ------ test/test_utils.py | 4 +- 8 files changed, 46 insertions(+), 305 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 394f453..9c35afa 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -47,31 +47,31 @@ jobs: run: | codecov - # macos: - # runs-on: macOS-latest - # strategy: - # max-parallel: 4 - # matrix: - # python-version: [3.7] + macos: + runs-on: macOS-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.7] - # steps: - # - uses: actions/checkout@v1 - # - name: Set up Python ${{ matrix.python-version }} - # uses: actions/setup-python@v1 - # with: - # python-version: ${{ matrix.python-version }} - # - name: Install dependencies - # run: | - # python -m pip install --upgrade pip - # pip install -r requirements.txt - # pip install pytest "pytest-cov<2.6" - # pip install -U "sklearn" - # - name: Install POT - # run: | - # pip install -e . - # - name: Run tests - # run: | - # python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pytest "pytest-cov<2.6" + pip install -U "sklearn" + - name: Install POT + run: | + pip install -e . + - name: Run tests + run: | + python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot windows: diff --git a/ot/lp/EMD.h b/ot/lp/EMD.h index 2adaace..c0fe7a3 100644 --- a/ot/lp/EMD.h +++ b/ot/lp/EMD.h @@ -32,9 +32,6 @@ enum ProblemType { int EMD_wrap(int n1,int n2, double *X, double *Y,double *D, double *G, double* alpha, double* beta, double *cost, int maxIter); -int EMD_wrap_return_sparse(int n1, int n2, double *X, double *Y, double *D, - long *iG, long *jG, double *G, long * nG, - double* alpha, double* beta, double *cost, int maxIter); #endif diff --git a/ot/lp/EMD_wrapper.cpp b/ot/lp/EMD_wrapper.cpp index 28e4af2..bc873ed 100644 --- a/ot/lp/EMD_wrapper.cpp +++ b/ot/lp/EMD_wrapper.cpp @@ -106,185 +106,3 @@ int EMD_wrap(int n1, int n2, double *X, double *Y, double *D, double *G, return ret; } - -int EMD_wrap_return_sparse(int n1, int n2, double *X, double *Y, double *D, - long *iG, long *jG, double *G, long * nG, - double* alpha, double* beta, double *cost, int maxIter) { - // beware M and C anre strored in row major C style!!! - - // Get the number of non zero coordinates for r and c and vectors - int n, m, i, cur; - - typedef FullBipartiteDigraph Digraph; - DIGRAPH_TYPEDEFS(FullBipartiteDigraph); - - // Get the number of non zero coordinates for r and c - n=0; - for (int i=0; i0) { - n++; - }else if(val<0){ - return INFEASIBLE; - } - } - m=0; - for (int i=0; i0) { - m++; - }else if(val<0){ - return INFEASIBLE; - } - } - - // Define the graph - - std::vector indI(n), indJ(m); - std::vector weights1(n), weights2(m); - Digraph di(n, m); - NetworkSimplexSimple net(di, true, n+m, n*m, maxIter); - - // Set supply and demand, don't account for 0 values (faster) - - cur=0; - for (int i=0; i0) { - weights1[ cur ] = val; - indI[cur++]=i; - } - } - - // Demand is actually negative supply... - - cur=0; - for (int i=0; i0) { - weights2[ cur ] = -val; - indJ[cur++]=i; - } - } - - // Define the graph - net.supplyMap(&weights1[0], n, &weights2[0], m); - - // Set the cost of each edge - for (int i=0; i0) - { - *cost += flow * (*(D+indI[i]*n2+indJ[j-n])); - - *(G+cur) = flow; - *(iG+cur) = indI[i]; - *(jG+cur) = indJ[j-n]; - *(alpha + indI[i]) = -net.potential(i); - *(beta + indJ[j-n]) = net.potential(j); - cur++; - } - } - *nG=cur; // nb of value +1 for numpy indexing - - } - - - return ret; -} - -int EMD_wrap_all_sparse(int n1, int n2, double *X, double *Y, - long *iD, long *jD, double *D, long nD, - long *iG, long *jG, double *G, long * nG, - double* alpha, double* beta, double *cost, int maxIter) { - // beware M and C anre strored in row major C style!!! - - // Get the number of non zero coordinates for r and c and vectors - int n, m, cur; - - typedef FullBipartiteDigraph Digraph; - DIGRAPH_TYPEDEFS(FullBipartiteDigraph); - - n=n1; - m=n2; - - - // Define the graph - - - std::vector weights2(m); - Digraph di(n, m); - NetworkSimplexSimple net(di, true, n+m, n*m, maxIter); - - // Set supply and demand, don't account for 0 values (faster) - - - // Demand is actually negative supply... - - cur=0; - for (int i=0; i0) { - weights2[ cur ] = -val; - } - } - - // Define the graph - net.supplyMap(X, n, &weights2[0], m); - - // Set the cost of each edge - for (int k=0; k0) - { - - *(G+cur) = flow; - *(iG+cur) = i; - *(jG+cur) = j-n; - *(alpha + i) = -net.potential(i); - *(beta + j-n) = net.potential(j); - cur++; - } - } - *nG=cur; // nb of value +1 for numpy indexing - - } - - - return ret; -} - diff --git a/ot/lp/__init__.py b/ot/lp/__init__.py index 8d1baa0..ad390c5 100644 --- a/ot/lp/__init__.py +++ b/ot/lp/__init__.py @@ -172,7 +172,7 @@ def estimate_dual_null_weights(alpha0, beta0, a, b, M): return center_ot_dual(alpha, beta, a, b) -def emd(a, b, M, numItermax=100000, log=False, dense=True, center_dual=True): +def emd(a, b, M, numItermax=100000, log=False, center_dual=True): r"""Solves the Earth Movers distance problem and returns the OT matrix @@ -207,10 +207,6 @@ def emd(a, b, M, numItermax=100000, log=False, dense=True, center_dual=True): log: bool, optional (default=False) If True, returns a dictionary containing the cost and dual variables. Otherwise returns only the optimal transportation matrix. - dense: boolean, optional (default=True) - If True, returns math:`\gamma` as a dense ndarray of shape (ns, nt). - Otherwise returns a sparse representation using scipy's `coo_matrix` - format. center_dual: boolean, optional (default=True) If True, centers the dual potential using function :ref:`center_ot_dual`. @@ -267,25 +263,14 @@ def emd(a, b, M, numItermax=100000, log=False, dense=True, center_dual=True): asel = a != 0 bsel = b != 0 - if dense: - G, cost, u, v, result_code = emd_c(a, b, M, numItermax, dense) - - if center_dual: - u, v = center_ot_dual(u, v, a, b) + G, cost, u, v, result_code = emd_c(a, b, M, numItermax) - if np.any(~asel) or np.any(~bsel): - u, v = estimate_dual_null_weights(u, v, a, b, M) - - else: - Gv, iG, jG, cost, u, v, result_code = emd_c(a, b, M, numItermax, dense) - G = coo_matrix((Gv, (iG, jG)), shape=(a.shape[0], b.shape[0])) - - if center_dual: - u, v = center_ot_dual(u, v, a, b) - - if np.any(~asel) or np.any(~bsel): - u, v = estimate_dual_null_weights(u, v, a, b, M) + if center_dual: + u, v = center_ot_dual(u, v, a, b) + if np.any(~asel) or np.any(~bsel): + u, v = estimate_dual_null_weights(u, v, a, b, M) + result_code_string = check_result(result_code) if log: log = {} @@ -299,7 +284,7 @@ def emd(a, b, M, numItermax=100000, log=False, dense=True, center_dual=True): def emd2(a, b, M, processes=multiprocessing.cpu_count(), - numItermax=100000, log=False, dense=True, return_matrix=False, + numItermax=100000, log=False, return_matrix=False, center_dual=True): r"""Solves the Earth Movers distance problem and returns the loss @@ -404,11 +389,8 @@ def emd2(a, b, M, processes=multiprocessing.cpu_count(), if log or return_matrix: def f(b): bsel = b != 0 - if dense: - G, cost, u, v, result_code = emd_c(a, b, M, numItermax, dense) - else: - Gv, iG, jG, cost, u, v, result_code = emd_c(a, b, M, numItermax, dense) - G = coo_matrix((Gv, (iG, jG)), shape=(a.shape[0], b.shape[0])) + + G, cost, u, v, result_code = emd_c(a, b, M, numItermax) if center_dual: u, v = center_ot_dual(u, v, a, b) @@ -428,11 +410,7 @@ def emd2(a, b, M, processes=multiprocessing.cpu_count(), else: def f(b): bsel = b != 0 - if dense: - G, cost, u, v, result_code = emd_c(a, b, M, numItermax, dense) - else: - Gv, iG, jG, cost, u, v, result_code = emd_c(a, b, M, numItermax, dense) - G = coo_matrix((Gv, (iG, jG)), shape=(a.shape[0], b.shape[0])) + G, cost, u, v, result_code = emd_c(a, b, M, numItermax) if center_dual: u, v = center_ot_dual(u, v, a, b) @@ -440,7 +418,6 @@ def emd2(a, b, M, processes=multiprocessing.cpu_count(), if np.any(~asel) or np.any(~bsel): u, v = estimate_dual_null_weights(u, v, a, b, M) - result_code_string = check_result(result_code) check_result(result_code) return cost diff --git a/ot/lp/emd_wrap.pyx b/ot/lp/emd_wrap.pyx index d345fd4..b6bda47 100644 --- a/ot/lp/emd_wrap.pyx +++ b/ot/lp/emd_wrap.pyx @@ -20,9 +20,6 @@ import warnings cdef extern from "EMD.h": int EMD_wrap(int n1,int n2, double *X, double *Y,double *D, double *G, double* alpha, double* beta, double *cost, int maxIter) - int EMD_wrap_return_sparse(int n1, int n2, double *X, double *Y, double *D, - long *iG, long *jG, double *G, long * nG, - double* alpha, double* beta, double *cost, int maxIter) cdef enum ProblemType: INFEASIBLE, OPTIMAL, UNBOUNDED, MAX_ITER_REACHED @@ -38,13 +35,10 @@ def check_result(result_code): message = "numItermax reached before optimality. Try to increase numItermax." warnings.warn(message) return message - - - - + @cython.boundscheck(False) @cython.wraparound(False) -def emd_c(np.ndarray[double, ndim=1, mode="c"] a, np.ndarray[double, ndim=1, mode="c"] b, np.ndarray[double, ndim=2, mode="c"] M, int max_iter, bint dense): +def emd_c(np.ndarray[double, ndim=1, mode="c"] a, np.ndarray[double, ndim=1, mode="c"] b, np.ndarray[double, ndim=2, mode="c"] M, int max_iter): """ Solves the Earth Movers distance problem and returns the optimal transport matrix @@ -83,8 +77,6 @@ def emd_c(np.ndarray[double, ndim=1, mode="c"] a, np.ndarray[double, ndim=1, mod max_iter : int The maximum number of iterations before stopping the optimization algorithm if it has not converged. - dense : bool - Return a sparse transport matrix if set to False Returns ------- @@ -114,29 +106,13 @@ def emd_c(np.ndarray[double, ndim=1, mode="c"] a, np.ndarray[double, ndim=1, mod if not len(b): b=np.ones((n2,))/n2 - if dense: - # init OT matrix - G=np.zeros([n1, n2]) - - # calling the function - result_code = EMD_wrap(n1, n2, a.data, b.data, M.data, G.data, alpha.data, beta.data, &cost, max_iter) - - return G, cost, alpha, beta, result_code - - - else: - - # init sparse OT matrix - Gv=np.zeros(nmax) - iG=np.zeros(nmax,dtype=np.int) - jG=np.zeros(nmax,dtype=np.int) - - - result_code = EMD_wrap_return_sparse(n1, n2, a.data, b.data, M.data, iG.data, jG.data, Gv.data, &nG, alpha.data, beta.data, &cost, max_iter) - + # init OT matrix + G=np.zeros([n1, n2]) - return Gv[:nG], iG[:nG], jG[:nG], cost, alpha, beta, result_code + # calling the function + result_code = EMD_wrap(n1, n2, a.data, b.data, M.data, G.data, alpha.data, beta.data, &cost, max_iter) + return G, cost, alpha, beta, result_code @cython.boundscheck(False) diff --git a/ot/lp/network_simplex_simple.h b/ot/lp/network_simplex_simple.h index 498e921..5d93040 100644 --- a/ot/lp/network_simplex_simple.h +++ b/ot/lp/network_simplex_simple.h @@ -875,7 +875,7 @@ namespace lemon { c += Number(it->second) * Number(_cost[it->first]); return c;*/ - for (int i=0; i<_flow.size(); i++) + for (unsigned long i=0; i<_flow.size(); i++) c += _flow[i] * Number(_cost[i]); return c; @@ -1257,7 +1257,7 @@ namespace lemon { u = w; } _pred[u_in] = in_arc; - _forward[u_in] = (u_in == _source[in_arc]); + _forward[u_in] = ((unsigned int)u_in == _source[in_arc]); _succ_num[u_in] = old_succ_num; // Set limits for updating _last_succ form v_in and v_out @@ -1418,7 +1418,6 @@ namespace lemon { template ProblemType start() { PivotRuleImpl pivot(*this); - double prevCost=-1; ProblemType retVal = OPTIMAL; // Perform heuristic initial pivots diff --git a/test/test_ot.py b/test/test_ot.py index 0f1357f..b7306f6 100644 --- a/test/test_ot.py +++ b/test/test_ot.py @@ -170,27 +170,6 @@ def test_emd_empty(): np.testing.assert_allclose(w, 0) -def test_emd_sparse(): - n = 100 - rng = np.random.RandomState(0) - - x = rng.randn(n, 2) - x2 = rng.randn(n, 2) - - M = ot.dist(x, x2) - - G = ot.emd([], [], M, dense=True) - - Gs = ot.emd([], [], M, dense=False) - - ws = ot.emd2([], [], M, dense=False) - - # check G is the same - np.testing.assert_allclose(G, Gs.todense()) - # check value - np.testing.assert_allclose(Gs.multiply(M).sum(), ws, rtol=1e-6) - - def test_emd2_multi(): n = 500 # nb bins @@ -222,12 +201,7 @@ def test_emd2_multi(): emdn = ot.emd2(a, b, M) ot.toc('multi proc : {} s') - ot.tic() - emdn2 = ot.emd2(a, b, M, dense=False) - ot.toc('multi proc : {} s') - np.testing.assert_allclose(emd1, emdn) - np.testing.assert_allclose(emd1, emdn2, rtol=1e-6) # emd loss multipro proc with log ot.tic() diff --git a/test/test_utils.py b/test/test_utils.py index 640598d..db9cda6 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -36,10 +36,10 @@ def test_tic_toc(): t2 = ot.toq() # test timing - np.testing.assert_allclose(0.5, t, rtol=1e-2, atol=1e-2) + np.testing.assert_allclose(0.5, t, rtol=1e-1, atol=1e-1) # test toc vs toq - np.testing.assert_allclose(t, t2, rtol=1e-2, atol=1e-2) + np.testing.assert_allclose(t, t2, rtol=1e-1, atol=1e-1) def test_kernel(): -- cgit v1.2.3 From 6426c182bc2546d00d18f7422d6dde150e09217c Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Thu, 23 Apr 2020 14:19:52 +0200 Subject: add platforms and remove pp --- .github/workflows/build_wheels.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 7c13c33..a1fabc9 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -2,6 +2,9 @@ name: Build dist and wheels on: release: + push: + branches: + - "wheels_multi" jobs: build_wheels: @@ -9,7 +12,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-18.04] + os: [ubuntu-18.04, macosx-latest, windows-latest] # macosx-latest, windows-latest steps: @@ -36,6 +39,7 @@ jobs: - name: Build wheel env: + CIBW_SKIP: "pp*-win*" CIBW_BEFORE_BUILD: "pip install numpy cython" run: | python -m cibuildwheel --output-dir wheelhouse -- cgit v1.2.3 From d2575b77e90e9cc94ee60bcd548ede16740ca2fc Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Thu, 23 Apr 2020 14:29:46 +0200 Subject: proper macos build --- .github/workflows/build_wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index a1fabc9..da1e18f 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -12,7 +12,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-18.04, macosx-latest, windows-latest] + os: [ubuntu-18.04, macos-latest, windows-latest] # macosx-latest, windows-latest steps: -- cgit v1.2.3 From d676bc70dd3d332973ce3700ae9d7f02865fffcd Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Thu, 23 Apr 2020 14:41:57 +0200 Subject: remove pipy for macosx --- .github/workflows/build_wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index da1e18f..2fc8db3 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -39,7 +39,7 @@ jobs: - name: Build wheel env: - CIBW_SKIP: "pp*-win*" + CIBW_SKIP: "pp*-win* pp*-macosx*" CIBW_BEFORE_BUILD: "pip install numpy cython" run: | python -m cibuildwheel --output-dir wheelhouse -- cgit v1.2.3 From c69006a975681c7f7d81dadba43b475aaae0c8ea Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Thu, 23 Apr 2020 14:55:08 +0200 Subject: trigger CIs --- .github/workflows/pythonpackage.yml | 1 - 1 file changed, 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 311c283..4b6c320 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -73,7 +73,6 @@ jobs: run: | python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot - windows: runs-on: windows-2019 strategy: -- cgit v1.2.3 From 46445382a4ee7743bb6f254fdeaf9d0abdae44d6 Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Thu, 23 Apr 2020 14:58:52 +0200 Subject: final version --- .github/workflows/build_wheels.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 2fc8db3..1a4c173 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -2,9 +2,6 @@ name: Build dist and wheels on: release: - push: - branches: - - "wheels_multi" jobs: build_wheels: @@ -12,8 +9,8 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-18.04, macos-latest, windows-latest] - # macosx-latest, windows-latest + os: [ubuntu-latest, macos-latest, windows-latest] + # macos-latest, windows-latest steps: - uses: actions/checkout@v1 @@ -39,7 +36,7 @@ jobs: - name: Build wheel env: - CIBW_SKIP: "pp*-win* pp*-macosx*" + CIBW_SKIP: "pp*-win* pp*-macosx*" # remove pypy on mac and win (wrong version) CIBW_BEFORE_BUILD: "pip install numpy cython" run: | python -m cibuildwheel --output-dir wheelhouse -- cgit v1.2.3 From 39f7ad7a6f1a52ede3602c4c721c0314c2b5fc5e Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Thu, 23 Apr 2020 16:29:35 +0200 Subject: trigger CIs --- .github/workflows/pythonpackage.yml | 2 ++ 1 file changed, 2 insertions(+) (limited to '.github/workflows') diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 4b6c320..0792059 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -47,6 +47,7 @@ jobs: run: | codecov + macos: runs-on: macOS-latest strategy: @@ -73,6 +74,7 @@ jobs: run: | python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot + windows: runs-on: windows-2019 strategy: -- cgit v1.2.3 From 53265dbd5530aee37a33f42e1243b26422d62acf Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Fri, 24 Apr 2020 11:12:42 +0200 Subject: build wheels on push to master --- .github/workflows/build_wheels.yml | 3 +++ 1 file changed, 3 insertions(+) (limited to '.github/workflows') diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 1a4c173..be1719b 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -2,6 +2,9 @@ name: Build dist and wheels on: release: + push: + branches: + - "master" jobs: build_wheels: -- cgit v1.2.3 From 96c113b2c6e9a0428deb0743e369130971d6f4d5 Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Mon, 4 May 2020 09:13:54 +0200 Subject: rename files and add pull request for proper status in pr --- .github/workflows/build_tests.yml | 103 ++++++++++++++++++++++++++++++ .github/workflows/circleci-redirector.yml | 13 ++++ .github/workflows/main.yml | 13 ---- .github/workflows/pythonpackage.yml | 102 ----------------------------- 4 files changed, 116 insertions(+), 115 deletions(-) create mode 100644 .github/workflows/build_tests.yml create mode 100644 .github/workflows/circleci-redirector.yml delete mode 100644 .github/workflows/main.yml delete mode 100644 .github/workflows/pythonpackage.yml (limited to '.github/workflows') diff --git a/.github/workflows/build_tests.yml b/.github/workflows/build_tests.yml new file mode 100644 index 0000000..652655f --- /dev/null +++ b/.github/workflows/build_tests.yml @@ -0,0 +1,103 @@ +name: build + +on: + push: + branches: + - '**' + pull_request: + create: + branches: + - 'master' + tags: + - '**' + +jobs: + linux: + + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.5, 3.6, 3.7, 3.8] + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install flake8 pytest "pytest-cov<2.6" codecov + pip install -U "sklearn" + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 examples/ ot/ test/ --count --max-line-length=127 --statistics + - name: Install POT + run: | + pip install -e . + - name: Run tests + run: | + python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot + - name: Upload codecov + run: | + codecov + + + macos: + runs-on: macOS-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.7] + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pytest "pytest-cov<2.6" + pip install -U "sklearn" + - name: Install POT + run: | + pip install -e . + - name: Run tests + run: | + python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot + + + windows: + runs-on: windows-2019 + strategy: + max-parallel: 4 + matrix: + python-version: [3.7] + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pytest "pytest-cov<2.6" + pip install -U "sklearn" + - name: Install POT + run: | + pip install -e . + - name: Run tests + run: | + python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot diff --git a/.github/workflows/circleci-redirector.yml b/.github/workflows/circleci-redirector.yml new file mode 100644 index 0000000..ae7bfca --- /dev/null +++ b/.github/workflows/circleci-redirector.yml @@ -0,0 +1,13 @@ +name: circleci-redirector +on: [status] +jobs: + circleci_artifacts_redirector_job: + runs-on: ubuntu-latest + name: Run CircleCI artifacts redirector + steps: + - name: GitHub Action step + uses: larsoner/circleci-artifacts-redirector-action@master + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + artifact-path: 0/dev/index.html + circleci-jobs: build_docs diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index ae7bfca..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: circleci-redirector -on: [status] -jobs: - circleci_artifacts_redirector_job: - runs-on: ubuntu-latest - name: Run CircleCI artifacts redirector - steps: - - name: GitHub Action step - uses: larsoner/circleci-artifacts-redirector-action@master - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - artifact-path: 0/dev/index.html - circleci-jobs: build_docs diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml deleted file mode 100644 index 0792059..0000000 --- a/.github/workflows/pythonpackage.yml +++ /dev/null @@ -1,102 +0,0 @@ -name: build - -on: - push: - branches: - - '**' - create: - branches: - - 'master' - tags: - - '**' - -jobs: - linux: - - runs-on: ubuntu-latest - strategy: - max-parallel: 4 - matrix: - python-version: [3.5, 3.6, 3.7, 3.8] - - steps: - - uses: actions/checkout@v1 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install flake8 pytest "pytest-cov<2.6" codecov - pip install -U "sklearn" - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 examples/ ot/ test/ --count --max-line-length=127 --statistics - - name: Install POT - run: | - pip install -e . - - name: Run tests - run: | - python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot - - name: Upload codecov - run: | - codecov - - - macos: - runs-on: macOS-latest - strategy: - max-parallel: 4 - matrix: - python-version: [3.7] - - steps: - - uses: actions/checkout@v1 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install pytest "pytest-cov<2.6" - pip install -U "sklearn" - - name: Install POT - run: | - pip install -e . - - name: Run tests - run: | - python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot - - - windows: - runs-on: windows-2019 - strategy: - max-parallel: 4 - matrix: - python-version: [3.7] - - steps: - - uses: actions/checkout@v1 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install pytest "pytest-cov<2.6" - pip install -U "sklearn" - - name: Install POT - run: | - pip install -e . - - name: Run tests - run: | - python -m pytest -v test/ ot/ --doctest-modules --ignore ot/gpu/ --cov=ot -- cgit v1.2.3 From e65c1f745cf2eacc6672727e7a3869efd8318768 Mon Sep 17 00:00:00 2001 From: Romain Tavenard Date: Mon, 4 May 2020 11:19:35 +0200 Subject: [WIP] Improved docs and changed scipy version (#163) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Improved docs and changed scipy version * Fixed dependency bug in setup.py * dependencies set to minimal versions for tests * add requirements file * added minimal version build for scipy (testing 1.2) * bugfix in minimal deps build * (yet another) bugfix in minimal deps build * minimal deps now reflect README.md * minimal deps: no autograd nor pymanopt * refactored workflow names * minimal deps: no doctests * minimal deps: numpy 1.16 * trigger GH Actions on PR * better merge * re-add minimal-deps... * bugfix in yaml * enforce np>=1.16 * enforce scipy and cython versions too * requires / install_requires * requires / install_requires / requires * setup_requires Co-authored-by: Rémi Flamary --- .github/requirements_strict.txt | 7 ++ .github/workflows/build_tests.yml | 32 ++++++- README.md | 2 +- .../barycenters/plot_free_support_barycenter.py | 6 +- examples/domain-adaptation/plot_otda_d2.py | 2 +- examples/domain-adaptation/plot_otda_mapping.py | 4 +- .../plot_otda_mapping_colors_images.py | 1 + examples/gromov/plot_barycenter_fgw.py | 11 ++- examples/gromov/plot_fgw.py | 10 +- examples/plot_compute_emd.py | 4 +- examples/plot_optim_OTreg.py | 6 +- examples/plot_screenkhorn_1D.py | 7 +- examples/plot_stochastic.py | 101 +++++++++------------ requirements.txt | 2 +- setup.py | 3 +- 15 files changed, 110 insertions(+), 88 deletions(-) create mode 100644 .github/requirements_strict.txt (limited to '.github/workflows') diff --git a/.github/requirements_strict.txt b/.github/requirements_strict.txt new file mode 100644 index 0000000..d7539c5 --- /dev/null +++ b/.github/requirements_strict.txt @@ -0,0 +1,7 @@ +numpy==1.16.* +scipy==1.0.* +cython==0.23.* +matplotlib +cvxopt +scikit-learn +pytest diff --git a/.github/workflows/build_tests.yml b/.github/workflows/build_tests.yml index 652655f..41b08b3 100644 --- a/.github/workflows/build_tests.yml +++ b/.github/workflows/build_tests.yml @@ -2,9 +2,9 @@ name: build on: push: - branches: - - '**' + pull_request: + create: branches: - 'master' @@ -49,6 +49,34 @@ jobs: codecov + linux-minimal-deps: + + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.6] + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r .github/requirements_strict.txt + pip install pytest + pip install -U "sklearn" + - name: Install POT + run: | + pip install -e . + - name: Run tests + run: | + python -m pytest -v test/ ot/ --ignore ot/gpu/ + + macos: runs-on: macOS-latest strategy: diff --git a/README.md b/README.md index b9b8f45..5ee4cee 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ year={2017} The library has been tested on Linux, MacOSX and Windows. It requires a C++ compiler for building/installing the EMD solver and relies on the following Python modules: -- Numpy (>=1.11) +- Numpy (>=1.16) - Scipy (>=1.0) - Cython (>=0.23) - Matplotlib (>=1.5) diff --git a/examples/barycenters/plot_free_support_barycenter.py b/examples/barycenters/plot_free_support_barycenter.py index 64b89e4..27ddc8e 100644 --- a/examples/barycenters/plot_free_support_barycenter.py +++ b/examples/barycenters/plot_free_support_barycenter.py @@ -4,7 +4,7 @@ 2D free support Wasserstein barycenters of distributions ==================================================== -Illustration of 2D Wasserstein barycenters if discributions that are weighted +Illustration of 2D Wasserstein barycenters if distributions are weighted sum of diracs. """ @@ -21,7 +21,7 @@ import ot ############################################################################## # Generate data # ------------- -#%% parameters and data generation + N = 3 d = 2 measures_locations = [] @@ -46,7 +46,7 @@ for i in range(N): ############################################################################## # Compute free support barycenter -# ------------- +# ------------------------------- k = 10 # number of Diracs of the barycenter X_init = np.random.normal(0., 1., (k, d)) # initial Dirac locations diff --git a/examples/domain-adaptation/plot_otda_d2.py b/examples/domain-adaptation/plot_otda_d2.py index f49a570..d8b2a93 100644 --- a/examples/domain-adaptation/plot_otda_d2.py +++ b/examples/domain-adaptation/plot_otda_d2.py @@ -25,7 +25,7 @@ import ot import ot.plot ############################################################################## -# generate data +# Generate data # ------------- n_samples_source = 150 diff --git a/examples/domain-adaptation/plot_otda_mapping.py b/examples/domain-adaptation/plot_otda_mapping.py index ded2bdf..d21d3c9 100644 --- a/examples/domain-adaptation/plot_otda_mapping.py +++ b/examples/domain-adaptation/plot_otda_mapping.py @@ -9,8 +9,8 @@ time both the coupling transport and approximate the transport map with either a linear or a kernelized mapping as introduced in [8]. [8] M. Perrot, N. Courty, R. Flamary, A. Habrard, - "Mapping estimation for discrete optimal transport", - Neural Information Processing Systems (NIPS), 2016. +"Mapping estimation for discrete optimal transport", +Neural Information Processing Systems (NIPS), 2016. """ # Authors: Remi Flamary diff --git a/examples/domain-adaptation/plot_otda_mapping_colors_images.py b/examples/domain-adaptation/plot_otda_mapping_colors_images.py index 9d3a7c7..ee5c8b0 100644 --- a/examples/domain-adaptation/plot_otda_mapping_colors_images.py +++ b/examples/domain-adaptation/plot_otda_mapping_colors_images.py @@ -9,6 +9,7 @@ estimation [8]. [6] Ferradans, S., Papadakis, N., Peyre, G., & Aujol, J. F. (2014). Regularized discrete optimal transport. SIAM Journal on Imaging Sciences, 7(3), 1853-1882. + [8] M. Perrot, N. Courty, R. Flamary, A. Habrard, "Mapping estimation for discrete optimal transport", Neural Information Processing Systems (NIPS), 2016. diff --git a/examples/gromov/plot_barycenter_fgw.py b/examples/gromov/plot_barycenter_fgw.py index 77b0370..3f81765 100644 --- a/examples/gromov/plot_barycenter_fgw.py +++ b/examples/gromov/plot_barycenter_fgw.py @@ -4,14 +4,15 @@ Plot graphs' barycenter using FGW ================================= -This example illustrates the computation barycenter of labeled graphs using FGW +This example illustrates the computation barycenter of labeled graphs using +FGW [18]. Requires networkx >=2 -.. [18] Vayer Titouan, Chapel Laetitia, Flamary R{\'e}mi, Tavenard Romain - and Courty Nicolas - "Optimal Transport for structured data with application on graphs" - International Conference on Machine Learning (ICML). 2019. +[18] Vayer Titouan, Chapel Laetitia, Flamary Rémi, Tavenard Romain +and Courty Nicolas +"Optimal Transport for structured data with application on graphs" +International Conference on Machine Learning (ICML). 2019. """ diff --git a/examples/gromov/plot_fgw.py b/examples/gromov/plot_fgw.py index 73e486e..97fe619 100644 --- a/examples/gromov/plot_fgw.py +++ b/examples/gromov/plot_fgw.py @@ -4,12 +4,12 @@ Plot Fused-gromov-Wasserstein ============================== -This example illustrates the computation of FGW for 1D measures[18]. +This example illustrates the computation of FGW for 1D measures [18]. -.. [18] Vayer Titouan, Chapel Laetitia, Flamary R{\'e}mi, Tavenard Romain - and Courty Nicolas - "Optimal Transport for structured data with application on graphs" - International Conference on Machine Learning (ICML). 2019. +[18] Vayer Titouan, Chapel Laetitia, Flamary Rémi, Tavenard Romain +and Courty Nicolas +"Optimal Transport for structured data with application on graphs" +International Conference on Machine Learning (ICML). 2019. """ diff --git a/examples/plot_compute_emd.py b/examples/plot_compute_emd.py index 3340115..527a847 100644 --- a/examples/plot_compute_emd.py +++ b/examples/plot_compute_emd.py @@ -4,8 +4,8 @@ Plot multiple EMD ================= -Shows how to compute multiple EMD and Sinkhorn with two differnt -ground metrics and plot their values for diffeent distributions. +Shows how to compute multiple EMD and Sinkhorn with two different +ground metrics and plot their values for different distributions. """ diff --git a/examples/plot_optim_OTreg.py b/examples/plot_optim_OTreg.py index 51e2fdc..5eb15bd 100644 --- a/examples/plot_optim_OTreg.py +++ b/examples/plot_optim_OTreg.py @@ -6,7 +6,7 @@ Regularized OT with generic solver Illustrates the use of the generic solver for regularized OT with user-designed regularization term. It uses Conditional gradient as in [6] and -generalized Conditional Gradient as proposed in [5][7]. +generalized Conditional Gradient as proposed in [5,7]. [5] N. Courty; R. Flamary; D. Tuia; A. Rakotomamonjy, Optimal Transport for @@ -14,8 +14,8 @@ Domain Adaptation, in IEEE Transactions on Pattern Analysis and Machine Intelligence , vol.PP, no.99, pp.1-1. [6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). -Regularized discrete optimal transport. SIAM Journal on Imaging Sciences, -7(3), 1853-1882. +Regularized discrete optimal transport. SIAM Journal on Imaging +Sciences, 7(3), 1853-1882. [7] Rakotomamonjy, A., Flamary, R., & Courty, N. (2015). Generalized conditional gradient: analysis of convergence and applications. diff --git a/examples/plot_screenkhorn_1D.py b/examples/plot_screenkhorn_1D.py index 840ead8..785642a 100644 --- a/examples/plot_screenkhorn_1D.py +++ b/examples/plot_screenkhorn_1D.py @@ -4,8 +4,11 @@ 1D Screened optimal transport =============================== -This example illustrates the computation of Screenkhorn: -Screening Sinkhorn Algorithm for Optimal transport. +This example illustrates the computation of Screenkhorn [26]. + +[26] Alaya M. Z., Bérar M., Gasso G., Rakotomamonjy A. (2019). +Screening Sinkhorn Algorithm for Regularized Optimal Transport, +Advances in Neural Information Processing Systems 33 (NeurIPS). """ # Author: Mokhtar Z. Alaya diff --git a/examples/plot_stochastic.py b/examples/plot_stochastic.py index 742f8d9..3a1ef31 100644 --- a/examples/plot_stochastic.py +++ b/examples/plot_stochastic.py @@ -1,10 +1,18 @@ """ -========================== +=================== Stochastic examples -========================== +=================== This example is designed to show how to use the stochatic optimization -algorithms for descrete and semicontinous measures from the POT library. +algorithms for discrete and semi-continuous measures from the POT library. + +[18] Genevay, A., Cuturi, M., Peyré, G. & Bach, F. +Stochastic Optimization for Large-scale Optimal Transport. +Advances in Neural Information Processing Systems (2016). + +[19] Seguy, V., Bhushan Damodaran, B., Flamary, R., Courty, N., Rolet, A. & +Blondel, M. Large-scale Optimal Transport and Mapping Estimation. +International Conference on Learning Representation (2018) """ @@ -19,16 +27,14 @@ import ot.plot ############################################################################# -# COMPUTE TRANSPORTATION MATRIX FOR SEMI-DUAL PROBLEM -############################################################################# -############################################################################# -# DISCRETE CASE: +# Compute the Transportation Matrix for the Semi-Dual Problem +# ----------------------------------------------------------- # -# Sample two discrete measures for the discrete case -# --------------------------------------------- +# Discrete case +# ````````````` # -# Define 2 discrete measures a and b, the points where are defined the source -# and the target measures and finally the cost matrix c. +# Sample two discrete measures for the discrete case and compute their cost +# matrix c. n_source = 7 n_target = 4 @@ -44,12 +50,7 @@ Y_target = rng.randn(n_target, 2) M = ot.dist(X_source, Y_target) ############################################################################# -# # Call the "SAG" method to find the transportation matrix in the discrete case -# --------------------------------------------- -# -# Define the method "SAG", call ot.solve_semi_dual_entropic and plot the -# results. method = "SAG" sag_pi = ot.stochastic.solve_semi_dual_entropic(a, b, M, reg, method, @@ -57,14 +58,12 @@ sag_pi = ot.stochastic.solve_semi_dual_entropic(a, b, M, reg, method, print(sag_pi) ############################################################################# -# SEMICONTINOUS CASE: +# Semi-Continuous Case +# ```````````````````` # # Sample one general measure a, one discrete measures b for the semicontinous -# case -# --------------------------------------------- -# -# Define one general measure a, one discrete measures b, the points where -# are defined the source and the target measures and finally the cost matrix c. +# case, the points where source and target measures are defined and compute the +# cost matrix. n_source = 7 n_target = 4 @@ -81,13 +80,8 @@ Y_target = rng.randn(n_target, 2) M = ot.dist(X_source, Y_target) ############################################################################# -# # Call the "ASGD" method to find the transportation matrix in the semicontinous -# case -# --------------------------------------------- -# -# Define the method "ASGD", call ot.solve_semi_dual_entropic and plot the -# results. +# case. method = "ASGD" asgd_pi, log_asgd = ot.stochastic.solve_semi_dual_entropic(a, b, M, reg, method, @@ -96,23 +90,17 @@ print(log_asgd['alpha'], log_asgd['beta']) print(asgd_pi) ############################################################################# -# # Compare the results with the Sinkhorn algorithm -# --------------------------------------------- -# -# Call the Sinkhorn algorithm from POT sinkhorn_pi = ot.sinkhorn(a, b, M, reg) print(sinkhorn_pi) ############################################################################## -# PLOT TRANSPORTATION MATRIX -############################################################################## - -############################################################################## -# Plot SAG results -# ---------------- +# Plot Transportation Matrices +# ```````````````````````````` +# +# For SAG pl.figure(4, figsize=(5, 5)) ot.plot.plot1D_mat(a, b, sag_pi, 'semi-dual : OT matrix SAG') @@ -120,8 +108,7 @@ pl.show() ############################################################################## -# Plot ASGD results -# ----------------- +# For ASGD pl.figure(4, figsize=(5, 5)) ot.plot.plot1D_mat(a, b, asgd_pi, 'semi-dual : OT matrix ASGD') @@ -129,8 +116,7 @@ pl.show() ############################################################################## -# Plot Sinkhorn results -# --------------------- +# For Sinkhorn pl.figure(4, figsize=(5, 5)) ot.plot.plot1D_mat(a, b, sinkhorn_pi, 'OT matrix Sinkhorn') @@ -138,17 +124,14 @@ pl.show() ############################################################################# -# COMPUTE TRANSPORTATION MATRIX FOR DUAL PROBLEM -############################################################################# -############################################################################# -# SEMICONTINOUS CASE: +# Compute the Transportation Matrix for the Dual Problem +# ------------------------------------------------------ # -# Sample one general measure a, one discrete measures b for the semicontinous -# case -# --------------------------------------------- +# Semi-continuous case +# ```````````````````` # -# Define one general measure a, one discrete measures b, the points where -# are defined the source and the target measures and finally the cost matrix c. +# Sample one general measure a, one discrete measures b for the semi-continuous +# case and compute the cost matrix c. n_source = 7 n_target = 4 @@ -169,10 +152,7 @@ M = ot.dist(X_source, Y_target) ############################################################################# # # Call the "SGD" dual method to find the transportation matrix in the -# semicontinous case -# --------------------------------------------- -# -# Call ot.solve_dual_entropic and plot the results. +# semi-continuous case sgd_dual_pi, log_sgd = ot.stochastic.solve_dual_entropic(a, b, M, reg, batch_size, numItermax, @@ -183,7 +163,7 @@ print(sgd_dual_pi) ############################################################################# # # Compare the results with the Sinkhorn algorithm -# --------------------------------------------- +# ``````````````````````````````````````````````` # # Call the Sinkhorn algorithm from POT @@ -191,8 +171,10 @@ sinkhorn_pi = ot.sinkhorn(a, b, M, reg) print(sinkhorn_pi) ############################################################################## -# Plot SGD results -# ----------------- +# Plot Transportation Matrices +# ```````````````````````````` +# +# For SGD pl.figure(4, figsize=(5, 5)) ot.plot.plot1D_mat(a, b, sgd_dual_pi, 'dual : OT matrix SGD') @@ -200,8 +182,7 @@ pl.show() ############################################################################## -# Plot Sinkhorn results -# --------------------- +# For Sinkhorn pl.figure(4, figsize=(5, 5)) ot.plot.plot1D_mat(a, b, sinkhorn_pi, 'OT matrix Sinkhorn') diff --git a/requirements.txt b/requirements.txt index bee22f7..331dd57 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ numpy -scipy>=1.0 +scipy>=1.3 cython matplotlib autograd diff --git a/setup.py b/setup.py index 4640d00..91c24d9 100755 --- a/setup.py +++ b/setup.py @@ -67,7 +67,8 @@ setup(name='POT', scripts=[], data_files=[], requires=["numpy", "scipy", "cython"], - install_requires=["numpy", "scipy", "cython"], + setup_requires=["numpy>=1.16", "scipy>=1.0", "cython>=0.23"], + install_requires=["numpy>=1.16", "scipy>=1.0", "cython>=0.23"], classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', -- cgit v1.2.3 From 27facf1f22176eabae9f710e8dd528c8aa2c9c6b Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Mon, 4 May 2020 15:20:49 +0200 Subject: test build wheels --- .github/workflows/build_wheels.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index be1719b..a4b980b 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -4,7 +4,7 @@ on: release: push: branches: - - "master" + - "**" jobs: build_wheels: @@ -39,7 +39,7 @@ jobs: - name: Build wheel env: - CIBW_SKIP: "pp*-win* pp*-macosx*" # remove pypy on mac and win (wrong version) + CIBW_SKIP: "pp*-win* pp*-macosx* cp2*" # remove pypy on mac and win (wrong version) CIBW_BEFORE_BUILD: "pip install numpy cython" run: | python -m cibuildwheel --output-dir wheelhouse -- cgit v1.2.3 From 43fcd147158d0cdf67f3bdc9a73716fdd5fac6be Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Mon, 4 May 2020 15:33:33 +0200 Subject: remove whelels pypy --- .github/workflows/build_wheels.yml | 2 +- RELEASES.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index a4b980b..babe7fa 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -39,7 +39,7 @@ jobs: - name: Build wheel env: - CIBW_SKIP: "pp*-win* pp*-macosx* cp2*" # remove pypy on mac and win (wrong version) + CIBW_SKIP: "pp*-win* pp*-macosx* cp2* pp2*" # remove pypy on mac and win (wrong version) CIBW_BEFORE_BUILD: "pip install numpy cython" run: | python -m cibuildwheel --output-dir wheelhouse diff --git a/RELEASES.md b/RELEASES.md index 0fc9240..dbcb4cb 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -5,7 +5,7 @@ This is the new stable release for POT. We have a lot of changes in the documentation and several new features such as Partial OT, Unbalanced and Multi Sources OT Domain Adaptation and several bug fixes. One important change is that we have created a the GitHub organization [PythonOT](https://github.com/PythonOT) that now owns the main POT repository [https://github.com/PythonOT/POT](https://github.com/PythonOT/POT) and the repository for the new documentation hosted at [https://PythonOT.github.io/](https://PythonOT.github.io/). -This is the first release where the Python 2.7 tests have been removed. Most of the toolbox should still work but this is the last release where we release Python 2.7 wheels. +This is the first release where the Python 2.7 tests have been removed. Most of the toolbox should still work but we do not offer support for Python 2.7 and will close related Issues. A lot of changes have been done to the documentation that is now hosted on [https://PythonOT.github.io/](https://PythonOT.github.io/) instead of readthedocs. It was a hard choice but readthedocs did not allow us to run sphinx-gallery to update our beautiful examples and it was a huge amount of work to maintain it. The documentation is now automatically compiled and updated on merge. We also removed the notebooks from the repository for space reason and also because they are all available in the [example gallery](https://pythonot.github.io/auto_examples/index.html). Note that now the output of the documentation build for each commit in the PR is available to check that the doc builds correctly before merging which was not possible with readthedoc. -- cgit v1.2.3 From f0770af36cb2fef01156f3a30222eeace19a5352 Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Mon, 4 May 2020 15:46:23 +0200 Subject: really remove pypy --- .github/workflows/build_wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index babe7fa..7c61a06 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -39,7 +39,7 @@ jobs: - name: Build wheel env: - CIBW_SKIP: "pp*-win* pp*-macosx* cp2* pp2*" # remove pypy on mac and win (wrong version) + CIBW_SKIP: "pp*-win* pp*-macosx* cp2* pp*" # remove pypy on mac and win (wrong version) CIBW_BEFORE_BUILD: "pip install numpy cython" run: | python -m cibuildwheel --output-dir wheelhouse -- cgit v1.2.3 From ba752bdba9a6733ebbb835cdbc59f1195a849245 Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Mon, 4 May 2020 16:06:22 +0200 Subject: back to build wheels on master --- .github/workflows/build_wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 7c61a06..662a604 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -4,7 +4,7 @@ on: release: push: branches: - - "**" + - "master" jobs: build_wheels: -- cgit v1.2.3