Skip to content

first attempt to support sphinx-gallery #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -54,7 +56,9 @@ def __getattr__(cls, name):
'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.
Expand Down Expand Up @@ -316,3 +320,11 @@ def __getattr__(cls, name):

# 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'}
}
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Contents

self
all
examples
auto_examples

.. include:: readme.rst
:start-line: 6
Expand Down
3 changes: 3 additions & 0 deletions examples/demo_OTDA_2D.py → examples/plot_OTDA_2D.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# -*- coding: utf-8 -*-
"""
===============================================
demo of Optimal transport for domain adaptation
===============================================

"""

import numpy as np
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# -*- coding: utf-8 -*-
"""
===============================================
demo of Optimal transport for domain adaptation
===============================================

"""

import matplotlib.pylab as pl
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -106,8 +108,3 @@
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)")





Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions examples/demo_OT_1D.py → examples/plot_OT_1D.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
"""
=============================
Demo for 1D optimal transport
=============================

@author: rflamary
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,3 @@
pl.plot(xt[:,0],xt[:,1],'xr',label='Target samples')
pl.legend(loc=0)
pl.title('OT matrix Sinkhorn with samples')


File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ numpy
scipy
cython
matplotlib
sphinx-gallery