Skip to content

Commit e3b1150

Browse files
committed
Merge branch 'master' into DA
2 parents d3d8689 + 4758107 commit e3b1150

File tree

8 files changed

+79
-18
lines changed

8 files changed

+79
-18
lines changed

MANIFEST.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
graft ot/lp/
2+
include README.md
3+
include ot/lp/core.h
4+
include ot/lp/EMD.h
5+
include ot/lp/emd.pyx
6+
include ot/lp/full_bipartitegraph.h
7+
include ot/lp/network_simplex_simple.h

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ sremove :
3333

3434
clean :
3535
$(PYTHON) setup.py clean
36+
37+
uploadpypi:
38+
python setup.py register
39+
python setup.py sdist upload -r pypi
40+
3641

3742
notebook :
3843
ipython notebook --matplotlib=inline --notebook-dir=examples/

README.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
# POT: Python Optimal Transport
22

3+
4+
[![Documentation Status](https://readthedocs.org/projects/pot/badge/?version=latest)](http://pot.readthedocs.io/en/latest/?badge=latest)
5+
36
This open source Python library provide several solvers for optimization problems related to Optimal Transport for signal, image processing and machine learning.
47

58
It provides the following solvers:
9+
610
* OT solver for the linear program/ Earth Movers Distance [1].
711
* Entropic regularization OT solver with Sinkhorn Knopp Algorithm [2].
812
* Bregman projections for Wasserstein barycenter [3] and unmixing [4].
913
* Optimal transport for domain adaptation with group lasso regularization [5]
1014
* Conditional gradient [6] and Generalized conditional gradient for regularized OT [7].
1115

16+
We are also currently working on the following features:
17+
18+
- [ ] Image color adaptation demo
19+
- [ ] Scikit-learn inspired classes for domain adaptation
20+
- [ ] Mapping estimation as proposed in [8]
21+
1222
Some demonstrations (both in Python and Jupyter Notebook format) are available in the examples folder.
1323

1424
## Installation
@@ -17,13 +27,24 @@ The Library has been tested on Linux and MacOSX. It requires a C++ compiler for
1727

1828
- Numpy (>=1.11)
1929
- Scipy (>=0.17)
30+
- Cython (>=0.23)
31+
- Matplotlib (>=1.5)
32+
33+
34+
Under debian based linux the dependencies can be installed with
35+
```
36+
sudo apt-get install python-numpy python-scipy python-matplotlib cython
37+
```
2038

2139
To install the library, you can install it locally (after downloading it) on you machine using
2240
```
2341
python setup.py install --user
2442
```
2543

26-
44+
The toolbox is also available on PyPI with a possibly slightly older version. You can install it with:
45+
```
46+
pip install POT
47+
```
2748

2849
After a correct installation, you should be able to import the module without errors:
2950
```python
@@ -34,19 +55,20 @@ Note that for easier access the module is name ot instead of pot.
3455

3556
## Examples
3657

37-
The examples folder contain several examples and use case for the library.
58+
The examples folder contain several examples and use case for the library. The full documentation is available on [Readthedoc](http://pot.readthedocs.io/)
3859

3960
Here is a list of the Python notebook if you want a quick look:
4061

41-
* [1D optimal transport](examples/Demo_1D_OT.ipynb)
42-
* [2D optimal transport on empirical distributions](examples/Demo_2D_OT_samples.ipynb)
43-
* [1D Wasserstein barycenter](examples/Demo_1D_barycenter.ipynb)
44-
* [OT with user provided regularization](examples/Demo_Optim_OTreg.ipynb)
62+
* [1D optimal transport](https://github.com/rflamary/POT/blob/master/examples/Demo_1D_OT.ipynb)
63+
* [2D optimal transport on empirical distributions](https://github.com/rflamary/POT/blob/master/examples/Demo_2D_OT_samples.ipynb)
64+
* [1D Wasserstein barycenter](https://github.com/rflamary/POT/blob/master/examples/Demo_1D_barycenter.ipynb)
65+
* [OT with user provided regularization](https://github.com/rflamary/POT/blob/master/examples/Demo_Optim_OTreg.ipynb)
4566

4667

4768
## Acknowledgements
4869

4970
The contributors to this library are:
71+
5072
* [Rémi Flamary](http://remi.flamary.com/)
5173
* [Nicolas Courty](http://people.irisa.fr/Nicolas.Courty/)
5274
* [Laetitia Chapel](http://people.irisa.fr/Laetitia.Chapel/)
@@ -73,3 +95,5 @@ This toolbox benefit a lot from open source research and we would like to thank
7395
[6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). Regularized discrete optimal transport. SIAM Journal on Imaging Sciences, 7(3), 1853-1882.
7496

7597
[7] Rakotomamonjy, A., Flamary, R., & Courty, N. (2015). Generalized conditional gradient: analysis of convergence and applications. arXiv preprint arXiv:1510.06567.
98+
99+
[8] M. Perrot, N. Courty, R. Flamary, A. Habrard, "Mapping estimation for discrete optimal transport", Neural Information Processing Systems (NIPS), 2016.

docs/source/conf.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,19 @@
1414

1515
import sys
1616
import os
17+
from unittest.mock import MagicMock
1718

1819
sys.path.insert(0, os.path.abspath("../.."))
1920

21+
22+
class Mock(MagicMock):
23+
@classmethod
24+
def __getattr__(cls, name):
25+
return Mock()
26+
27+
MOCK_MODULES = [ 'emd','ot.lp.emd']
28+
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
29+
2030
# If extensions (or modules to document with autodoc) are in another directory,
2131
# add these directories to sys.path here. If the directory is relative to the
2232
# documentation root, use os.path.abspath to make it absolute, like shown here.

docs/source/index.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ Contents
3030
all
3131
examples
3232

33-
Examples
34-
--------
35-
36-
37-
3833

3934
References
4035
----------

ot/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@
1717
# utils functions
1818
from .utils import dist, unif
1919

20+
__version__ = "0.1.6"
21+
2022
__all__ = ["emd", "sinkhorn", "utils", 'datasets', 'bregman', 'lp', 'plot',
2123
'dist', 'unif', 'barycenter', 'sinkhorn_lpl1_mm', 'da', 'optim']

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[metadata]
2+
description-file = README.md

setup.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,39 @@
33
from setuptools import setup, find_packages
44
from codecs import open
55
from os import path
6-
import numpy
76
from setuptools.extension import Extension
87
from Cython.Build import cythonize
9-
8+
import numpy
9+
import re
10+
import os
1011

1112
here = path.abspath(path.dirname(__file__))
1213

1314

1415

15-
import os
16+
1617
#import glob
1718

18-
version='0.1'
19+
# dirty but working
20+
__version__ = re.search(
21+
r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]', # It excludes inline comment too
22+
open('ot/__init__.py').read()).group(1)
23+
# The beautiful part is, I don't even need to check exceptions here.
24+
# If something messes up, let the build process fail noisy, BEFORE my release!
1925

2026
ROOT = os.path.abspath(os.path.dirname(__file__))
21-
README = open(os.path.join(ROOT, 'README.md')).read()
27+
28+
29+
# convert markdown readme to rst in pypandoc installed
30+
try:
31+
import pypandoc
32+
README = pypandoc.convert('README.md', 'rst')
33+
except (IOError, ImportError):
34+
README = open(os.path.join(ROOT, 'README.md')).read()
35+
2236

2337
setup(name='POT',
24-
version=version,
38+
version=__version__,
2539
description='Python Optimal Transport Library',
2640
long_description=README,
2741
author=u'Remi Flamary, Nicolas Courty',
@@ -35,10 +49,12 @@
3549
language="c++", # generate and compile C++ code,
3650
include_dirs=[numpy.get_include(),os.path.join(ROOT,'ot/lp')])),
3751
platforms=['linux','macosx','windows'],
52+
download_url='https://github.com/rflamary/POT/archive/V{}.tar.gz'.format(__version__),
3853
license = 'MIT',
3954
scripts=[],
4055
data_files=[],
41-
requires=["numpy (>=1.11)","scipy (>=0.17)"],
56+
requires=["numpy (>=1.11)","scipy (>=0.17)","cython (>=0.23)","matplotlib (>=1.5)"],
57+
install_requires=["numpy (>=1.11)","scipy (>=0.17)","cython (>=0.23)","matplotlib (>=1.5)"],
4258
classifiers=[
4359
'Development Status :: 4 - Beta',
4460
'Intended Audience :: Developers',

0 commit comments

Comments
 (0)