Skip to content

Commit 81b2796

Browse files
authored
Merge pull request #27 from rflamary/autonb
auto notebooks + release update (fixes #16)
2 parents e70d542 + 7fea2cd commit 81b2796

File tree

221 files changed

+12652
-7009
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+12652
-7009
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
Nicolas Courty <[email protected]> Nicolas Courty <[email protected]>
22
Nicolas Courty <[email protected]> ncourty <[email protected]>
3+
Nicolas Courty <[email protected]> Nicolas Courty <[email protected]>
34
Léo Gautheron <[email protected]> Leo gautheron <[email protected]>

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ help :
1515
build :
1616
$(PYTHON) setup.py build
1717

18+
buildext :
19+
$(PYTHON) setup.py build_ext --inplace
20+
1821
install :
1922
$(PYTHON) setup.py install --user
2023

README.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,21 @@ The examples folder contain several examples and use case for the library. The f
112112

113113
Here is a list of the Python notebooks available [here](https://github.com/rflamary/POT/blob/master/notebooks/) if you want a quick look:
114114

115-
* [1D optimal transport](https://github.com/rflamary/POT/blob/master/notebooks/Demo_1D_OT.ipynb)
116-
* [OT Ground Loss](https://github.com/rflamary/POT/blob/master/notebooks/Demo_Ground_Loss.ipynb)
117-
* [Multiple EMD computation](https://github.com/rflamary/POT/blob/master/notebooks/Demo_Compute_EMD.ipynb)
118-
* [2D optimal transport on empirical distributions](https://github.com/rflamary/POT/blob/master/notebooks/Demo_2D_OT_samples.ipynb)
119-
* [1D Wasserstein barycenter](https://github.com/rflamary/POT/blob/master/notebooks/Demo_1D_barycenter.ipynb)
120-
* [OT with user provided regularization](https://github.com/rflamary/POT/blob/master/notebooks/Demo_Optim_OTreg.ipynb)
121-
* [Domain adaptation with optimal transport](https://github.com/rflamary/POT/blob/master/notebooks/Demo_2D_OT_DomainAdaptation.ipynb)
122-
* [Color transfer in images](https://github.com/rflamary/POT/blob/master/notebooks/Demo_Image_ColorAdaptation.ipynb)
123-
* [OT mapping estimation for domain adaptation](https://github.com/rflamary/POT/blob/master/notebooks/Demo_2D_OTmapping_DomainAdaptation.ipynb)
124-
* [OT mapping estimation for color transfer in images](https://github.com/rflamary/POT/blob/master/notebooks/Demo_Image_ColorAdaptation_mapping.ipynb)
125-
* [Wasserstein Discriminant Analysis](https://github.com/rflamary/POT/blob/master/notebooks/Demo_Wasserstein_Discriminant_Analysis.ipynb)
115+
* [1D optimal transport](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_1D.ipynb)
116+
* [OT Ground Loss](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_L1_vs_L2.ipynb)
117+
* [Multiple EMD computation](https://github.com/rflamary/POT/blob/master/notebooks/plot_compute_emd.ipynb)
118+
* [2D optimal transport on empirical distributions](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_2D_samples.ipynb)
119+
* [1D Wasserstein barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_barycenter_1D.ipynb)
120+
* [OT with user provided regularization](https://github.com/rflamary/POT/blob/master/notebooks/plot_optim_OTreg.ipynb)
121+
* [Domain adaptation with optimal transport](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_d2.ipynb)
122+
* [Color transfer in images](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_color_images.ipynb)
123+
* [OT mapping estimation for domain adaptation](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_mapping.ipynb)
124+
* [OT mapping estimation for color transfer in images](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_mapping_colors_images.ipynb)
125+
* [Wasserstein Discriminant Analysis](https://github.com/rflamary/POT/blob/master/notebooks/plot_WDA.ipynb)
126+
* [Gromov Wasserstein](https://github.com/rflamary/POT/blob/master/notebooks/plot_gromov.ipynb)
127+
* [Gromov Wasserstein Barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_gromov_barycenter.ipynb)
128+
129+
126130

127131
You can also see the notebooks with [Jupyter nbviewer](https://nbviewer.jupyter.org/github/rflamary/POT/tree/master/notebooks/).
128132

RELEASES.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# POT Releases
2+
3+
## 0.4 Community edition
4+
*15 Sep 2017*
5+
6+
This release contains a lot of contribution from new contributors.
7+
8+
9+
#### Features
10+
11+
* Automatic notebooks and doc update (PR #27)
12+
* Add gromov Wasserstein solver and Gromov Barycenters (PR #23)
13+
* emd and emd2 can now return dual variables and have max_iter (PR #29 and PR #25)
14+
* New domain adaptation classes compatible with scikit-learn (PR #22)
15+
* Proper tests with pytest on travis (PR #19)
16+
* PEP 8 tests (PR #13)
17+
18+
#### Closed issues
19+
20+
* emd convergence problem du to fixed max iterations (#24)
21+
* Semi supervised DA error (#26)
22+
23+
## 0.3.1
24+
*11 Jul 2017*
25+
26+
* Correct bug in emd on windows
27+
28+
## 0.3 Summer release
29+
*7 Jul 2017*
30+
31+
* emd* and sinkhorn* are now performed in parallel for multiple target distributions
32+
* emd and sinkhorn are for OT matrix computation
33+
* emd2 and sinkhorn2 are for OT loss computation
34+
* new notebooks for emd computation and Wasserstein Discriminant Analysis
35+
* relocate notebooks
36+
* update documentation
37+
* clean_zeros(a,b,M) for removimg zeros in sparse distributions
38+
* GPU implementations for sinkhorn and group lasso regularization
39+
40+
41+
## V0.2
42+
*7 Apr 2017*
43+
44+
* New dimensionality reduction method (WDA)
45+
* Efficient method emd2 returns only tarnsport (in paralell if several histograms given)
46+
47+
48+
49+
## V0.1.11 New years resolution
50+
*5 Jan 2017*
51+
52+
* Add sphinx gallery for better documentation
53+
* Small efficiency tweak in sinkhorn
54+
* Add simple tic() toc() functions for timing
55+
56+
57+
## V0.1.10
58+
*7 Nov 2016*
59+
* numerical stabilization for sinkhorn (log domain and epsilon scaling)
60+
61+
## V0.1.9 DA classes and mapping
62+
*4 Nov 2016*
63+
64+
* Update classes and examples for domain adaptation
65+
* Joint OT matrix and mapping estimation
66+
67+
## V0.1.7
68+
*31 Oct 2016*
69+
70+
* Original Domain adaptation classes
71+
72+
73+
74+
## PyPI version 0.1.3
75+
76+
* pipy works
77+
78+
## First pre-release
79+
*28 Oct 2016*
80+
81+
It provides the following solvers:
82+
* OT solver for the linear program/ Earth Movers Distance.
83+
* Entropic regularization OT solver with Sinkhorn Knopp Algorithm.
84+
* Bregman projections for Wasserstein barycenter [3] and unmixing.
85+
* Optimal transport for domain adaptation with group lasso regularization
86+
* Conditional gradient and Generalized conditional gradient for regularized OT.
87+
88+
Some demonstrations (both in Python and Jupyter Notebook format) are available in the examples folder.

docs/cache_nbrun

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"plot_otda_mapping_colors_images.ipynb": "4f0587a00a3c082799a75a0ed36e9ce1", "plot_optim_OTreg.ipynb": "71d3c106b3f395a6b1001078a6ca6f8d", "plot_otda_color_images.ipynb": "d047d635f4987c81072383241590e21f", "plot_WDA.ipynb": "27f8de4c6d7db46497076523673eedfb", "plot_OT_L1_vs_L2.ipynb": "e15219bf651a7e39e7c5c3934069894c", "plot_barycenter_1D.ipynb": "6fd8167f98816dc832fe0c58b1d5527b", "plot_otda_classes.ipynb": "44bb8cd93317b5d342cd62e26d9bbe60", "plot_otda_d2.ipynb": "8ac4fd2ff899df0858ce1e5fead37f33", "plot_otda_mapping.ipynb": "d335a15af828aaa3439a1c67570d79d6", "plot_gromov.ipynb": "9d0893ec68851f200d0ca806bcbe847f", "plot_compute_emd.ipynb": "bd95981189df6adcb113d9b360ead734", "plot_OT_1D.ipynb": "e44c83f6112388ae18657cb0ad76d0e9", "plot_gromov_barycenter.ipynb": "a4d9636685394ceb13f26cdc613b9b5b", "plot_otda_semi_supervised.ipynb": "0261d339a692e339e15d3634488905cc", "plot_OT_2D_samples.ipynb": "3f125714daa35ff3cfe5dae1f71265c4"}

docs/nb_build

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
4+
# remove comment
5+
sed -i "s/#'sphinx\_gallery/'sphinx\_gallery/" source/conf.py
6+
sed -i "s/sys.modules.update/#sys.modules.update/" source/conf.py
7+
8+
make html
9+
10+
# put comment again
11+
sed -i "s/'sphinx\_gallery/#'sphinx\_gallery/" source/conf.py
12+
sed -i "s/#sys.modules.update/sys.modules.update/" source/conf.py
13+
14+
#rsync --out-format="%n" --update source/auto_examples/*.ipynb ../notebooks2
15+
./nb_run_conv

docs/nb_run_conv

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
"""
4+
5+
Convert sphinx gallery notebook from empty to image filled
6+
7+
Created on Fri Sep 1 16:43:45 2017
8+
9+
@author: rflamary
10+
"""
11+
12+
import sys
13+
import json
14+
import glob
15+
import hashlib
16+
import subprocess
17+
18+
import os
19+
20+
cache_file='cache_nbrun'
21+
22+
path_doc='source/auto_examples/'
23+
path_nb='../notebooks/'
24+
25+
def load_json(fname):
26+
try:
27+
f=open(fname)
28+
nb=json.load(f)
29+
f.close()
30+
except (OSError, IOError) :
31+
nb={}
32+
return nb
33+
34+
def save_json(fname,nb):
35+
f=open(fname,'w')
36+
f.write(json.dumps(nb))
37+
f.close()
38+
39+
40+
def md5(fname):
41+
hash_md5 = hashlib.md5()
42+
with open(fname, "rb") as f:
43+
for chunk in iter(lambda: f.read(4096), b""):
44+
hash_md5.update(chunk)
45+
return hash_md5.hexdigest()
46+
47+
def to_update(fname,cache):
48+
if fname in cache:
49+
if md5(path_doc+fname)==cache[fname]:
50+
res=False
51+
else:
52+
res=True
53+
else:
54+
res=True
55+
56+
return res
57+
58+
def update(fname,cache):
59+
60+
# jupyter nbconvert --to notebook --execute mynotebook.ipynb --output targte
61+
subprocess.check_call(['cp',path_doc+fname,path_nb])
62+
print(' '.join(['jupyter','nbconvert','--to','notebook','--ExecutePreprocessor.timeout=600','--execute',path_nb+fname,'--inplace']))
63+
subprocess.check_call(['jupyter','nbconvert','--to','notebook','--ExecutePreprocessor.timeout=600','--execute',path_nb+fname,'--inplace'])
64+
cache[fname]=md5(path_doc+fname)
65+
66+
67+
68+
cache=load_json(cache_file)
69+
70+
lst_file=glob.glob(path_doc+'*.ipynb')
71+
72+
lst_file=[os.path.basename(name) for name in lst_file]
73+
74+
for fname in lst_file:
75+
if to_update(fname,cache):
76+
print('Updating file: {}'.format(fname))
77+
update(fname,cache)
78+
save_json(cache_file,cache)
79+
80+
81+
82+
Binary file not shown.
Binary file not shown.

docs/source/auto_examples/demo_OT_1D_test.ipynb

Lines changed: 0 additions & 54 deletions
This file was deleted.

docs/source/auto_examples/demo_OT_1D_test.py

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)