summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Gramfort <alexandre.gramfort@m4x.org>2016-12-02 12:49:38 +0100
committerAlexandre Gramfort <alexandre.gramfort@m4x.org>2016-12-02 12:57:25 +0100
commitf439f777084690ecbf54bcd8d67dadc883fffa31 (patch)
tree56c8a160fb6edcdaca8ca6ce6de1949b9bc33b77
parent8dbfd3edae649f5f3e87be4a3ce446c59729b2f7 (diff)
first attempt to support sphinx-gallery
-rw-r--r--docs/source/conf.py30
-rw-r--r--docs/source/index.rst2
-rw-r--r--examples/plot_OTDA_2D.py (renamed from examples/demo_OTDA_2D.py)3
-rw-r--r--examples/plot_OTDA_classes.py (renamed from examples/demo_OTDA_classes.py)3
-rw-r--r--examples/plot_OTDA_color_images.py (renamed from examples/demo_OTDA_color_images.py)2
-rw-r--r--examples/plot_OTDA_mapping.py (renamed from examples/demo_OTDA_mapping.py)7
-rw-r--r--examples/plot_OTDA_mapping_color_images.py (renamed from examples/demo_OTDA_mapping_color_images.py)3
-rw-r--r--examples/plot_OT_1D.py (renamed from examples/demo_OT_1D.py)2
-rw-r--r--examples/plot_OT_2D_samples.py (renamed from examples/demo_OT_2D_samples.py)2
-rw-r--r--examples/plot_barycenter_1D.py (renamed from examples/demo_barycenter_1D.py)0
-rw-r--r--examples/plot_optim_OTreg.py (renamed from examples/demo_optim_OTreg.py)0
-rw-r--r--requirements.txt1
12 files changed, 37 insertions, 18 deletions
diff --git a/docs/source/conf.py b/docs/source/conf.py
index f48a868..61505cc 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -15,23 +15,25 @@
import sys
import os
import re
+import sphinx_gallery
+
#try:
-from unittest.mock import MagicMock
+# from unittest.mock import MagicMock
#except ImportError:
# from mock import MagicMock
-sys.path.insert(0, os.path.abspath("../.."))
+# sys.path.insert(0, os.path.abspath("../.."))
#sys.setrecursionlimit(1500)
-class Mock(MagicMock):
- @classmethod
- def __getattr__(cls, name):
- return Mock()
+# class Mock(MagicMock):
+# @classmethod
+# def __getattr__(cls, name):
+# return Mock()
-MOCK_MODULES = [ 'emd','ot.lp.emd']
-sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
+# MOCK_MODULES = [ 'emd','ot.lp.emd']
+# sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@@ -54,7 +56,9 @@ extensions = [
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.ifconfig',
- 'sphinx.ext.viewcode', 'sphinx.ext.napoleon'
+ 'sphinx.ext.viewcode',
+ 'sphinx.ext.napoleon',
+ 'sphinx_gallery.gen_gallery',
]
# Add any paths that contain templates here, relative to this directory.
@@ -316,3 +320,11 @@ texinfo_documents = [
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
+
+sphinx_gallery_conf = {
+ 'examples_dirs': '../../examples',
+ 'gallery_dirs': 'auto_examples',
+ 'reference_url': {
+ 'numpy': 'http://docs.scipy.org/doc/numpy-1.9.1',
+ 'scipy': 'http://docs.scipy.org/doc/scipy-0.17.0/reference'}
+}
diff --git a/docs/source/index.rst b/docs/source/index.rst
index 024c4e9..e3c4d36 100644
--- a/docs/source/index.rst
+++ b/docs/source/index.rst
@@ -14,7 +14,7 @@ Contents
self
all
- examples
+ auto_examples
.. include:: readme.rst
:start-line: 6
diff --git a/examples/demo_OTDA_2D.py b/examples/plot_OTDA_2D.py
index fbaf56d..db04c5e 100644
--- a/examples/demo_OTDA_2D.py
+++ b/examples/plot_OTDA_2D.py
@@ -1,6 +1,9 @@
# -*- coding: utf-8 -*-
"""
+===============================================
demo of Optimal transport for domain adaptation
+===============================================
+
"""
import numpy as np
diff --git a/examples/demo_OTDA_classes.py b/examples/plot_OTDA_classes.py
index b2da7de..999be53 100644
--- a/examples/demo_OTDA_classes.py
+++ b/examples/plot_OTDA_classes.py
@@ -1,6 +1,9 @@
# -*- coding: utf-8 -*-
"""
+===============================================
demo of Optimal transport for domain adaptation
+===============================================
+
"""
import matplotlib.pylab as pl
diff --git a/examples/demo_OTDA_color_images.py b/examples/plot_OTDA_color_images.py
index 715707d..7ddaa2b 100644
--- a/examples/demo_OTDA_color_images.py
+++ b/examples/plot_OTDA_color_images.py
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
"""
+=====================================================================================
Demo of Optimal transport for domain adaptation with image color adaptation as in [6]
+=====================================================================================
[6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). Regularized discrete optimal transport. SIAM Journal on Imaging Sciences, 7(3), 1853-1882.
"""
diff --git a/examples/demo_OTDA_mapping.py b/examples/plot_OTDA_mapping.py
index 50c1df2..779fa76 100644
--- a/examples/demo_OTDA_mapping.py
+++ b/examples/plot_OTDA_mapping.py
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
"""
+=======================================================
Demo of OT mapping estimation for domain adaptation [8]
+=======================================================
[8] M. Perrot, N. Courty, R. Flamary, A. Habrard, "Mapping estimation for
discrete optimal transport", Neural Information Processing Systems (NIPS), 2016.
@@ -106,8 +108,3 @@ pl.subplot(2,2,4)
pl.scatter(xt[:,0],xt[:,1],c=yt,marker='o',label='Target samples',alpha=.2)
pl.scatter(xst_kernel[:,0],xst_kernel[:,1],c=ys,marker='+',label='Learned mapping')
pl.title("Estim. mapping (kernel)")
-
-
-
-
-
diff --git a/examples/demo_OTDA_mapping_color_images.py b/examples/plot_OTDA_mapping_color_images.py
index 2744f6c..0cd6c9c 100644
--- a/examples/demo_OTDA_mapping_color_images.py
+++ b/examples/plot_OTDA_mapping_color_images.py
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
"""
+======================================================================================================================
Demo of Optimal transport for domain adaptation with image color adaptation as in [6] with mapping estimation from [8]
+======================================================================================================================
[6] Ferradans, S., Papadakis, N., Peyré, 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.
-
"""
import numpy as np
diff --git a/examples/demo_OT_1D.py b/examples/plot_OT_1D.py
index df65a60..a8bbbd6 100644
--- a/examples/demo_OT_1D.py
+++ b/examples/plot_OT_1D.py
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
"""
+=============================
Demo for 1D optimal transport
+=============================
@author: rflamary
"""
diff --git a/examples/demo_OT_2D_samples.py b/examples/plot_OT_2D_samples.py
index e9ec78a..e55eff8 100644
--- a/examples/demo_OT_2D_samples.py
+++ b/examples/plot_OT_2D_samples.py
@@ -74,5 +74,3 @@ pl.plot(xs[:,0],xs[:,1],'+b',label='Source samples')
pl.plot(xt[:,0],xt[:,1],'xr',label='Target samples')
pl.legend(loc=0)
pl.title('OT matrix Sinkhorn with samples')
-
-
diff --git a/examples/demo_barycenter_1D.py b/examples/plot_barycenter_1D.py
index 5466332..5466332 100644
--- a/examples/demo_barycenter_1D.py
+++ b/examples/plot_barycenter_1D.py
diff --git a/examples/demo_optim_OTreg.py b/examples/plot_optim_OTreg.py
index 0de6b08..0de6b08 100644
--- a/examples/demo_optim_OTreg.py
+++ b/examples/plot_optim_OTreg.py
diff --git a/requirements.txt b/requirements.txt
index d7b38b0..319f5e1 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,3 +2,4 @@ numpy
scipy
cython
matplotlib
+sphinx-gallery