Skip to content

Commit f439f77

Browse files
committed
first attempt to support sphinx-gallery
1 parent 8dbfd3e commit f439f77

12 files changed

+37
-18
lines changed

docs/source/conf.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,25 @@
1515
import sys
1616
import os
1717
import re
18+
import sphinx_gallery
19+
1820
#try:
19-
from unittest.mock import MagicMock
21+
# from unittest.mock import MagicMock
2022
#except ImportError:
2123
# from mock import MagicMock
2224

23-
sys.path.insert(0, os.path.abspath("../.."))
25+
# sys.path.insert(0, os.path.abspath("../.."))
2426
#sys.setrecursionlimit(1500)
2527

2628

2729

28-
class Mock(MagicMock):
29-
@classmethod
30-
def __getattr__(cls, name):
31-
return Mock()
30+
# class Mock(MagicMock):
31+
# @classmethod
32+
# def __getattr__(cls, name):
33+
# return Mock()
3234

33-
MOCK_MODULES = [ 'emd','ot.lp.emd']
34-
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
35+
# MOCK_MODULES = [ 'emd','ot.lp.emd']
36+
# sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
3537

3638
# If extensions (or modules to document with autodoc) are in another directory,
3739
# add these directories to sys.path here. If the directory is relative to the
@@ -54,7 +56,9 @@ def __getattr__(cls, name):
5456
'sphinx.ext.coverage',
5557
'sphinx.ext.mathjax',
5658
'sphinx.ext.ifconfig',
57-
'sphinx.ext.viewcode', 'sphinx.ext.napoleon'
59+
'sphinx.ext.viewcode',
60+
'sphinx.ext.napoleon',
61+
'sphinx_gallery.gen_gallery',
5862
]
5963

6064
# Add any paths that contain templates here, relative to this directory.
@@ -316,3 +320,11 @@ def __getattr__(cls, name):
316320

317321
# Example configuration for intersphinx: refer to the Python standard library.
318322
intersphinx_mapping = {'https://docs.python.org/': None}
323+
324+
sphinx_gallery_conf = {
325+
'examples_dirs': '../../examples',
326+
'gallery_dirs': 'auto_examples',
327+
'reference_url': {
328+
'numpy': 'http://docs.scipy.org/doc/numpy-1.9.1',
329+
'scipy': 'http://docs.scipy.org/doc/scipy-0.17.0/reference'}
330+
}

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Contents
1414

1515
self
1616
all
17-
examples
17+
auto_examples
1818

1919
.. include:: readme.rst
2020
:start-line: 6

examples/demo_OTDA_2D.py renamed to examples/plot_OTDA_2D.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# -*- coding: utf-8 -*-
22
"""
3+
===============================================
34
demo of Optimal transport for domain adaptation
5+
===============================================
6+
47
"""
58

69
import numpy as np

examples/demo_OTDA_classes.py renamed to examples/plot_OTDA_classes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# -*- coding: utf-8 -*-
22
"""
3+
===============================================
34
demo of Optimal transport for domain adaptation
5+
===============================================
6+
47
"""
58

69
import matplotlib.pylab as pl

examples/demo_OTDA_color_images.py renamed to examples/plot_OTDA_color_images.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# -*- coding: utf-8 -*-
22
"""
3+
=====================================================================================
34
Demo of Optimal transport for domain adaptation with image color adaptation as in [6]
5+
=====================================================================================
46
57
[6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). Regularized discrete optimal transport. SIAM Journal on Imaging Sciences, 7(3), 1853-1882.
68
"""

examples/demo_OTDA_mapping.py renamed to examples/plot_OTDA_mapping.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# -*- coding: utf-8 -*-
22
"""
3+
=======================================================
34
Demo of OT mapping estimation for domain adaptation [8]
5+
=======================================================
46
57
[8] M. Perrot, N. Courty, R. Flamary, A. Habrard, "Mapping estimation for
68
discrete optimal transport", Neural Information Processing Systems (NIPS), 2016.
@@ -106,8 +108,3 @@
106108
pl.scatter(xt[:,0],xt[:,1],c=yt,marker='o',label='Target samples',alpha=.2)
107109
pl.scatter(xst_kernel[:,0],xst_kernel[:,1],c=ys,marker='+',label='Learned mapping')
108110
pl.title("Estim. mapping (kernel)")
109-
110-
111-
112-
113-

examples/demo_OTDA_mapping_color_images.py renamed to examples/plot_OTDA_mapping_color_images.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# -*- coding: utf-8 -*-
22
"""
3+
======================================================================================================================
34
Demo of Optimal transport for domain adaptation with image color adaptation as in [6] with mapping estimation from [8]
5+
======================================================================================================================
46
57
[6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). Regularized
68
discrete optimal transport. SIAM Journal on Imaging Sciences, 7(3), 1853-1882.
79
[8] M. Perrot, N. Courty, R. Flamary, A. Habrard, "Mapping estimation for
810
discrete optimal transport", Neural Information Processing Systems (NIPS), 2016.
911
10-
1112
"""
1213

1314
import numpy as np

examples/demo_OT_1D.py renamed to examples/plot_OT_1D.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# -*- coding: utf-8 -*-
22
"""
3+
=============================
34
Demo for 1D optimal transport
5+
=============================
46
57
@author: rflamary
68
"""

examples/demo_OT_2D_samples.py renamed to examples/plot_OT_2D_samples.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,3 @@
7474
pl.plot(xt[:,0],xt[:,1],'xr',label='Target samples')
7575
pl.legend(loc=0)
7676
pl.title('OT matrix Sinkhorn with samples')
77-
78-
File renamed without changes.

0 commit comments

Comments
 (0)