From 1fb7ebe67a6d640a728e8f1ac5cfcea6bfba4ff1 Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 11:09:23 +0000 Subject: [PATCH 01/26] Attempting to fix docs but may break them --- doc/conf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index f1c120b5..e76bf8c9 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -33,7 +33,9 @@ on_rtd = os.environ.get('READTHEDOCS', None) == 'True' if on_rtd: sys.path.append("../GPy") os.system("pwd") - os.system("sphinx-apidoc -f -o . ../GPy") + os.system("cd ..") + os.system("sphinx-apidoc -f -o ./docs ./GPy") + os.system("cd ./docs") # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] From a605416d060e71441eae899798187eaddbaf9834 Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 11:15:54 +0000 Subject: [PATCH 02/26] Adding pylab mock module --- doc/conf.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/doc/conf.py b/doc/conf.py index e76bf8c9..6ebf2684 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -13,6 +13,29 @@ import sys, os +#Mocking uninstalled modules: https://read-the-docs.readthedocs.org/en/latest/faq.html +class Mock(object): + def __init__(self, *args, **kwargs): + pass + + def __call__(self, *args, **kwargs): + return Mock() + + @classmethod + def __getattr__(cls, name): + if name in ('__file__', '__path__'): + return '/dev/null' + elif name[0] == name[0].upper(): + mockType = type(name, (), {}) + mockType.__module__ = __name__ + return mockType + else: + return Mock() + +MOCK_MODULES = ['pylab'] +for mod_name in MOCK_MODULES: + sys.modules[mod_name] = Mock() + # 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 # documentation root, use os.path.abspath to make it absolute, like shown here. From 690bdcd62b32e993a398d9c148f039ea40cef1a9 Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 11:17:52 +0000 Subject: [PATCH 03/26] Same again --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 6ebf2684..cf574676 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -32,7 +32,7 @@ class Mock(object): else: return Mock() -MOCK_MODULES = ['pylab'] +MOCK_MODULES = ['pylab', 'packages.pylab'] for mod_name in MOCK_MODULES: sys.modules[mod_name] = Mock() From b94ea750485cbea132d46e95978e93d68c75b574 Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 11:22:59 +0000 Subject: [PATCH 04/26] Above again.... --- doc/conf.py | 52 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index cf574676..0baee5c8 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -14,32 +14,52 @@ import sys, os #Mocking uninstalled modules: https://read-the-docs.readthedocs.org/en/latest/faq.html + +# To avoid problem with ReadTheDocs and compiled extensions. class Mock(object): - def __init__(self, *args, **kwargs): + """Special Healpix values for masked pixels. + """ + pi = 3.141516 + class Axes(object): + pass + class Locator(object): + pass + class Normalize(object): + pass + def __init__(self, *args): + """Mock init + """ pass - def __call__(self, *args, **kwargs): + def __getattr__(self, name): + return Mock + + def __div__(self, x): return Mock() - @classmethod - def __getattr__(cls, name): - if name in ('__file__', '__path__'): - return '/dev/null' - elif name[0] == name[0].upper(): - mockType = type(name, (), {}) - mockType.__module__ = __name__ - return mockType - else: - return Mock() + def __getitem__(self, idx): + return str(Mock()) -MOCK_MODULES = ['pylab', 'packages.pylab'] -for mod_name in MOCK_MODULES: - sys.modules[mod_name] = Mock() +try: + import GPy +except exceptions.ImportError: + MOCK_MODULES = ['matplotlib', 'pylab', 'matplotlib.colors', + 'matplotlib.cbook', 'pyfits', + 'numpy'] + + for mod_name in MOCK_MODULES: + sys.modules[mod_name] = Mock() + + +# If your extensions are in another directory, add it here. If the directory +# is relative to the documentation root, use os.path.abspath to make it +# absolute, like shown here. +sys.path.append(os.path.abspath('.')) # 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 # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) +sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------------- From d4a20232c06f2dc519e6665c1de5d735f85fd881 Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 11:23:58 +0000 Subject: [PATCH 05/26] Forgot exceptions import --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 0baee5c8..ec7a129c 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -11,7 +11,7 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys, os +import sys, os, exceptions #Mocking uninstalled modules: https://read-the-docs.readthedocs.org/en/latest/faq.html From 3c8b0a030fe6f1aa2ef6bdc8bbd6c844613f1cbd Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 11:28:07 +0000 Subject: [PATCH 06/26] Adding extra mock... hopefully this won't carry on --- doc/conf.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index ec7a129c..ad577b94 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -26,6 +26,8 @@ class Mock(object): pass class Normalize(object): pass + class LinearSegmentedColormap(object): + pass def __init__(self, *args): """Mock init """ @@ -44,8 +46,7 @@ try: import GPy except exceptions.ImportError: MOCK_MODULES = ['matplotlib', 'pylab', 'matplotlib.colors', - 'matplotlib.cbook', 'pyfits', - 'numpy'] + 'matplotlib.cbook', 'pyfits', 'numpy'] for mod_name in MOCK_MODULES: sys.modules[mod_name] = Mock() From ba63b1a658876d508e53cc28b8268a7b408cb120 Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 11:29:09 +0000 Subject: [PATCH 07/26] Removed matplotlib mock --- doc/conf.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index ad577b94..b7114395 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -45,8 +45,7 @@ class Mock(object): try: import GPy except exceptions.ImportError: - MOCK_MODULES = ['matplotlib', 'pylab', 'matplotlib.colors', - 'matplotlib.cbook', 'pyfits', 'numpy'] + MOCK_MODULES = ['pylab'] for mod_name in MOCK_MODULES: sys.modules[mod_name] = Mock() From 9fec748be5870fc9c95e87c3d76086e329a98a57 Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 11:31:43 +0000 Subject: [PATCH 08/26] Added some more mocks --- doc/conf.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index b7114395..65558ab4 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -19,15 +19,15 @@ import sys, os, exceptions class Mock(object): """Special Healpix values for masked pixels. """ - pi = 3.141516 - class Axes(object): - pass - class Locator(object): - pass - class Normalize(object): - pass - class LinearSegmentedColormap(object): - pass + #pi = 3.141516 + #class Axes(object): + #pass + #class Locator(object): + #pass + #class Normalize(object): + #pass + #class LinearSegmentedColormap(object): + #pass def __init__(self, *args): """Mock init """ @@ -45,7 +45,11 @@ class Mock(object): try: import GPy except exceptions.ImportError: - MOCK_MODULES = ['pylab'] + MOCK_MODULES = ['matplotlib', 'pylab', 'matplotlib.colors', + 'matplotlib.cbook', 'pyfits', 'numpy', 'matplotlib', + 'matplotlib.cm', 'matplotlib.patches', 'matplotlib.projections', + 'matplotlib.projections.polar', 'matplotlib.pyplot', + 'matplotlib.text', 'matplotlib.ticker'] for mod_name in MOCK_MODULES: sys.modules[mod_name] = Mock() From 23aa9be73c761c5203c70d16afa3c2273eb4246a Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 11:39:30 +0000 Subject: [PATCH 09/26] More attempts at mocking --- doc/conf.py | 66 ++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 65558ab4..3b57514d 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -15,44 +15,42 @@ import sys, os, exceptions #Mocking uninstalled modules: https://read-the-docs.readthedocs.org/en/latest/faq.html -# To avoid problem with ReadTheDocs and compiled extensions. -class Mock(object): - """Special Healpix values for masked pixels. - """ - #pi = 3.141516 - #class Axes(object): - #pass - #class Locator(object): - #pass - #class Normalize(object): - #pass - #class LinearSegmentedColormap(object): - #pass - def __init__(self, *args): - """Mock init - """ - pass - - def __getattr__(self, name): - return Mock - - def __div__(self, x): - return Mock() - - def __getitem__(self, idx): - return str(Mock()) +# 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 +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath( + os.path.join(os.pardir,os.pardir))) +# -- Mocking modules for Read the Docs compatibility --------------------------- try: - import GPy -except exceptions.ImportError: - MOCK_MODULES = ['matplotlib', 'pylab', 'matplotlib.colors', - 'matplotlib.cbook', 'pyfits', 'numpy', 'matplotlib', - 'matplotlib.cm', 'matplotlib.patches', 'matplotlib.projections', - 'matplotlib.projections.polar', 'matplotlib.pyplot', - 'matplotlib.text', 'matplotlib.ticker'] + import scipy + import numpy + import pylab +except ImportError: + from mock import MagicMock + MOCK_MODULES = ['numpy', 'quantities', 'scipy', 'scipy.spatial', + 'scipy.spatial.distance'] for mod_name in MOCK_MODULES: - sys.modules[mod_name] = Mock() + sys.modules[mod_name] = MagicMock() + + # Needed for spykeutils.plot.Dialog.PlotDialog + #class QDialog: + #pass + #class PlotManager: + #pass + #sys.modules['PyQt4.QtGui'].QDialog = QDialog + #sys.modules['guiqwt.plot'].PlotManager = PlotManager + + ## Needed for spykeutils.plot.guiqwt_tools + #class CommandTool: + #pass + #class InteractiveTool: + #pass + #sys.modules['guiqwt.tools'].CommandTool = CommandTool + #sys.modules['guiqwt.tools'].InteractiveTool = InteractiveTool + +import Gpy # If your extensions are in another directory, add it here. If the directory From fe1c5431dfff3c45fb2349d41690f794eb52fbc5 Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 11:43:33 +0000 Subject: [PATCH 10/26] More fixing... --- doc/conf.py | 5 ++--- setup.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 3b57514d..77d69ba7 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -29,8 +29,7 @@ try: except ImportError: from mock import MagicMock - MOCK_MODULES = ['numpy', 'quantities', 'scipy', 'scipy.spatial', - 'scipy.spatial.distance'] + MOCK_MODULES = ['numpy', 'pylab', 'scipy'] for mod_name in MOCK_MODULES: sys.modules[mod_name] = MagicMock() @@ -50,7 +49,7 @@ except ImportError: #sys.modules['guiqwt.tools'].CommandTool = CommandTool #sys.modules['guiqwt.tools'].InteractiveTool = InteractiveTool -import Gpy +import GPy # If your extensions are in another directory, add it here. If the directory diff --git a/setup.py b/setup.py index 432b8b13..aec5e4ed 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ setup(name = 'GPy', long_description=read('README.md'), #ext_modules = [Extension(name = 'GPy.kern.lfmUpsilonf2py', # sources = ['GPy/kern/src/lfmUpsilonf2py.f90'])], - install_requires=['sympy', 'numpy>=1.6', 'scipy>=0.9','matplotlib>=1.1'], + install_requires=['sympy', 'numpy>=1.6', 'scipy>=0.9','matplotlib>=1.1', 'mock'], setup_requires=['sphinx'], cmdclass = {'build_sphinx': BuildDoc}, classifiers=[ From 57a79e0d7501c4446f850f0b24c6791d4ea0f865 Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 11:48:32 +0000 Subject: [PATCH 11/26] Importing mock better --- doc/conf.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 77d69ba7..a7a1bd98 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -27,7 +27,7 @@ try: import numpy import pylab except ImportError: - from mock import MagicMock + from unittest.mock import MagicMock MOCK_MODULES = ['numpy', 'pylab', 'scipy'] for mod_name in MOCK_MODULES: diff --git a/setup.py b/setup.py index aec5e4ed..432b8b13 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ setup(name = 'GPy', long_description=read('README.md'), #ext_modules = [Extension(name = 'GPy.kern.lfmUpsilonf2py', # sources = ['GPy/kern/src/lfmUpsilonf2py.f90'])], - install_requires=['sympy', 'numpy>=1.6', 'scipy>=0.9','matplotlib>=1.1', 'mock'], + install_requires=['sympy', 'numpy>=1.6', 'scipy>=0.9','matplotlib>=1.1'], setup_requires=['sphinx'], cmdclass = {'build_sphinx': BuildDoc}, classifiers=[ From 173375fec3ea4bb8a07a5b6854c1a1e62c1ae825 Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 11:57:48 +0000 Subject: [PATCH 12/26] More --- doc/conf.py | 74 +++++++++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index a7a1bd98..13481238 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -18,39 +18,7 @@ import sys, os, exceptions # 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 # documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath( - os.path.join(os.pardir,os.pardir))) - -# -- Mocking modules for Read the Docs compatibility --------------------------- -try: - import scipy - import numpy - import pylab -except ImportError: - from unittest.mock import MagicMock - - MOCK_MODULES = ['numpy', 'pylab', 'scipy'] - for mod_name in MOCK_MODULES: - sys.modules[mod_name] = MagicMock() - - # Needed for spykeutils.plot.Dialog.PlotDialog - #class QDialog: - #pass - #class PlotManager: - #pass - #sys.modules['PyQt4.QtGui'].QDialog = QDialog - #sys.modules['guiqwt.plot'].PlotManager = PlotManager - - ## Needed for spykeutils.plot.guiqwt_tools - #class CommandTool: - #pass - #class InteractiveTool: - #pass - #sys.modules['guiqwt.tools'].CommandTool = CommandTool - #sys.modules['guiqwt.tools'].InteractiveTool = InteractiveTool - -import GPy - +sys.path.insert(0, os.path.abspath('../')) # If your extensions are in another directory, add it here. If the directory # is relative to the documentation root, use os.path.abspath to make it @@ -340,3 +308,43 @@ epub_copyright = u'2013, Author' # Allow duplicate toc entries. #epub_tocdup = True + +############################################################################# +# +# Include constructors in all the docs +# Got this method from: +# http://stackoverflow.com/questions/5599254/how-to-use-sphinxs-autodoc-to-document-a-classs-init-self-method +def skip(app, what, name, obj, skip, options): + if name == "__init__": + return False + return skip + +def setup(app): + app.connect("autodoc-skip-member", skip) + +############################################################################# +# +# Mock out imports with C dependencies because ReadTheDocs can't build them. +class Mock(object): + def __init__(self, *args, **kwargs): + pass + + def __call__(self, *args, **kwargs): + return Mock() + + @classmethod + def __getattr__(cls, name): + if name in ('__file__', '__path__'): + return '/dev/null' + elif name[0] == name[0].upper(): + mockType = type(name, (), {}) + mockType.__module__ = __name__ + return mockType + else: + return Mock() + +MOCK_MODULES = ['matplotlib', 'matplotlib.pyplot', + 'numpy', 'numpy.linalg', 'pylab' + ] +for mod_name in MOCK_MODULES: + sys.modules[mod_name] = Mock() From 70222278a1381db306b28cea6105cf034826e84a Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 11:59:46 +0000 Subject: [PATCH 13/26] More... --- doc/conf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 13481238..e777b63d 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -322,6 +322,7 @@ def skip(app, what, name, obj, skip, options): def setup(app): app.connect("autodoc-skip-member", skip) + ############################################################################# # # Mock out imports with C dependencies because ReadTheDocs can't build them. @@ -344,7 +345,7 @@ class Mock(object): return Mock() MOCK_MODULES = ['matplotlib', 'matplotlib.pyplot', - 'numpy', 'numpy.linalg', 'pylab' + 'pylab' ] for mod_name in MOCK_MODULES: sys.modules[mod_name] = Mock() From 55ecc4306d7dead1ea2a6520dff72b61a651af7d Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 12:06:58 +0000 Subject: [PATCH 14/26] Remove matplotlib mock? --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index e777b63d..a5e7a5f3 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -344,7 +344,7 @@ class Mock(object): else: return Mock() -MOCK_MODULES = ['matplotlib', 'matplotlib.pyplot', +MOCK_MODULES = [#'matplotlib', 'matplotlib.pyplot', 'pylab' ] for mod_name in MOCK_MODULES: From 32e61ce1e8fc253b66f721cf3c9d7b21680f0146 Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 12:09:59 +0000 Subject: [PATCH 15/26] Adding requirements file? --- doc/doc-requirements.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 doc/doc-requirements.txt diff --git a/doc/doc-requirements.txt b/doc/doc-requirements.txt new file mode 100644 index 00000000..9f8ad0d0 --- /dev/null +++ b/doc/doc-requirements.txt @@ -0,0 +1,4 @@ +matplotlib +numpy +pylab +scipy From 98c06c1e7b51e3588e12233d5e70cfcb9aa38bcd Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 12:19:12 +0000 Subject: [PATCH 16/26] conf edit --- doc/conf.py | 8 ++++---- doc/doc-requirements.txt | 4 ---- 2 files changed, 4 insertions(+), 8 deletions(-) delete mode 100644 doc/doc-requirements.txt diff --git a/doc/conf.py b/doc/conf.py index a5e7a5f3..a6827fcf 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -18,7 +18,7 @@ import sys, os, exceptions # 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 # documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath('../')) +sys.path.insert(0, os.path.abspath('..')) # If your extensions are in another directory, add it here. If the directory # is relative to the documentation root, use os.path.abspath to make it @@ -45,9 +45,9 @@ on_rtd = os.environ.get('READTHEDOCS', None) == 'True' if on_rtd: sys.path.append("../GPy") os.system("pwd") - os.system("cd ..") - os.system("sphinx-apidoc -f -o ./docs ./GPy") - os.system("cd ./docs") + #os.system("cd ..") + os.system("sphinx-apidoc -f -o . ../GPy") + #os.system("cd ./docs") # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/doc/doc-requirements.txt b/doc/doc-requirements.txt deleted file mode 100644 index 9f8ad0d0..00000000 --- a/doc/doc-requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -matplotlib -numpy -pylab -scipy From 86f745f66ddf3a052846f8177e325e3b145dd800 Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 12:20:44 +0000 Subject: [PATCH 17/26] more --- doc/conf.py | 60 ++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index a6827fcf..e46e6bb6 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -43,7 +43,7 @@ extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] on_rtd = os.environ.get('READTHEDOCS', None) == 'True' if on_rtd: - sys.path.append("../GPy") + #sys.path.append("../GPy") os.system("pwd") #os.system("cd ..") os.system("sphinx-apidoc -f -o . ../GPy") @@ -314,38 +314,38 @@ epub_copyright = u'2013, Author' # Include constructors in all the docs # Got this method from: # http://stackoverflow.com/questions/5599254/how-to-use-sphinxs-autodoc-to-document-a-classs-init-self-method -def skip(app, what, name, obj, skip, options): - if name == "__init__": - return False - return skip +#def skip(app, what, name, obj, skip, options): + #if name == "__init__": + #return False + #return skip -def setup(app): - app.connect("autodoc-skip-member", skip) +#def setup(app): + #app.connect("autodoc-skip-member", skip) -############################################################################# -# -# Mock out imports with C dependencies because ReadTheDocs can't build them. -class Mock(object): - def __init__(self, *args, **kwargs): - pass +############################################################################## +## +## Mock out imports with C dependencies because ReadTheDocs can't build them. +#class Mock(object): + #def __init__(self, *args, **kwargs): + #pass - def __call__(self, *args, **kwargs): - return Mock() + #def __call__(self, *args, **kwargs): + #return Mock() - @classmethod - def __getattr__(cls, name): - if name in ('__file__', '__path__'): - return '/dev/null' - elif name[0] == name[0].upper(): - mockType = type(name, (), {}) - mockType.__module__ = __name__ - return mockType - else: - return Mock() + #@classmethod + #def __getattr__(cls, name): + #if name in ('__file__', '__path__'): + #return '/dev/null' + #elif name[0] == name[0].upper(): + #mockType = type(name, (), {}) + #mockType.__module__ = __name__ + #return mockType + #else: + #return Mock() -MOCK_MODULES = [#'matplotlib', 'matplotlib.pyplot', - 'pylab' - ] -for mod_name in MOCK_MODULES: - sys.modules[mod_name] = Mock() +#MOCK_MODULES = [#'matplotlib', 'matplotlib.pyplot', + #'pylab' + #] +#for mod_name in MOCK_MODULES: + #sys.modules[mod_name] = Mock() From 5c8aebdb596b63317ef59cb8bd0aac92f1ce9c38 Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 12:21:31 +0000 Subject: [PATCH 18/26] more --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index e46e6bb6..df2cae60 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -18,7 +18,7 @@ import sys, os, exceptions # 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 # documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath('..')) +#sys.path.insert(0, os.path.abspath('..')) # If your extensions are in another directory, add it here. If the directory # is relative to the documentation root, use os.path.abspath to make it From d63cd4ad7e0140112885d1ae1f7299383577455d Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 12:25:26 +0000 Subject: [PATCH 19/26] Back to the beginning? --- doc/conf.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index df2cae60..ee99e210 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -23,12 +23,12 @@ import sys, os, exceptions # If your extensions are in another directory, add it here. If the directory # is relative to the documentation root, use os.path.abspath to make it # absolute, like shown here. -sys.path.append(os.path.abspath('.')) +#sys.path.append(os.path.abspath('.')) # 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 # documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath('.')) +#sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------------- @@ -43,7 +43,7 @@ extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] on_rtd = os.environ.get('READTHEDOCS', None) == 'True' if on_rtd: - #sys.path.append("../GPy") + sys.path.append("../GPy") os.system("pwd") #os.system("cd ..") os.system("sphinx-apidoc -f -o . ../GPy") From 9758c90b164331a33152893a53385e962d7bb976 Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 12:27:27 +0000 Subject: [PATCH 20/26] Add just pylab mock back --- doc/conf.py | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index ee99e210..3ca2f6f1 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -326,26 +326,26 @@ epub_copyright = u'2013, Author' ############################################################################## ## ## Mock out imports with C dependencies because ReadTheDocs can't build them. -#class Mock(object): - #def __init__(self, *args, **kwargs): - #pass +class Mock(object): + def __init__(self, *args, **kwargs): + pass - #def __call__(self, *args, **kwargs): - #return Mock() + def __call__(self, *args, **kwargs): + return Mock() - #@classmethod - #def __getattr__(cls, name): - #if name in ('__file__', '__path__'): - #return '/dev/null' - #elif name[0] == name[0].upper(): - #mockType = type(name, (), {}) - #mockType.__module__ = __name__ - #return mockType - #else: - #return Mock() + @classmethod + def __getattr__(cls, name): + if name in ('__file__', '__path__'): + return '/dev/null' + elif name[0] == name[0].upper(): + mockType = type(name, (), {}) + mockType.__module__ = __name__ + return mockType + else: + return Mock() -#MOCK_MODULES = [#'matplotlib', 'matplotlib.pyplot', - #'pylab' - #] -#for mod_name in MOCK_MODULES: - #sys.modules[mod_name] = Mock() +MOCK_MODULES = [#'matplotlib', 'matplotlib.pyplot', + 'pylab' + ] +for mod_name in MOCK_MODULES: + sys.modules[mod_name] = Mock() From f208b49c3661815494dad73e5e465b5837e62640 Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 12:30:38 +0000 Subject: [PATCH 21/26] Added matplotlib to mock --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 3ca2f6f1..34464d94 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -344,7 +344,7 @@ class Mock(object): else: return Mock() -MOCK_MODULES = [#'matplotlib', 'matplotlib.pyplot', +MOCK_MODULES = ['matplotlib', 'matplotlib.pyplot', 'pylab' ] for mod_name in MOCK_MODULES: From b73245e1de2605936064cd4dd62aa9ec39b078ca Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 12:33:34 +0000 Subject: [PATCH 22/26] Moved mock to top --- doc/conf.py | 51 +++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 34464d94..3082f8c3 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -15,6 +15,31 @@ import sys, os, exceptions #Mocking uninstalled modules: https://read-the-docs.readthedocs.org/en/latest/faq.html +############################################################################## +## +## Mock out imports with C dependencies because ReadTheDocs can't build them. +class Mock(object): + def __init__(self, *args, **kwargs): + pass + + def __call__(self, *args, **kwargs): + return Mock() + + @classmethod + def __getattr__(cls, name): + if name in ('__file__', '__path__'): + return '/dev/null' + elif name[0] == name[0].upper(): + mockType = type(name, (), {}) + mockType.__module__ = __name__ + return mockType + else: + return Mock() + +MOCK_MODULES = ['matplotlib', 'matplotlib.pyplot', 'pylab' ] +for mod_name in MOCK_MODULES: + sys.modules[mod_name] = Mock() + # 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 # documentation root, use os.path.abspath to make it absolute, like shown here. @@ -323,29 +348,3 @@ epub_copyright = u'2013, Author' #app.connect("autodoc-skip-member", skip) -############################################################################## -## -## Mock out imports with C dependencies because ReadTheDocs can't build them. -class Mock(object): - def __init__(self, *args, **kwargs): - pass - - def __call__(self, *args, **kwargs): - return Mock() - - @classmethod - def __getattr__(cls, name): - if name in ('__file__', '__path__'): - return '/dev/null' - elif name[0] == name[0].upper(): - mockType = type(name, (), {}) - mockType.__module__ = __name__ - return mockType - else: - return Mock() - -MOCK_MODULES = ['matplotlib', 'matplotlib.pyplot', - 'pylab' - ] -for mod_name in MOCK_MODULES: - sys.modules[mod_name] = Mock() From c6339116a0090fa31459578fdeb8809e6611c5af Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 12:35:39 +0000 Subject: [PATCH 23/26] Added matplotlib color --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 3082f8c3..fe70071b 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -36,7 +36,7 @@ class Mock(object): else: return Mock() -MOCK_MODULES = ['matplotlib', 'matplotlib.pyplot', 'pylab' ] +MOCK_MODULES = ['matplotlib', 'matplotlib.color', 'matplotlib.pyplot', 'pylab' ] for mod_name in MOCK_MODULES: sys.modules[mod_name] = Mock() From d5bafc9bb92bed9e12803a61fc3288b0f5237629 Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 12:55:30 +0000 Subject: [PATCH 24/26] Testing differen mock --- doc/conf.py | 102 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 88 insertions(+), 14 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index fe70071b..a49a0c53 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -11,34 +11,108 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys, os, exceptions +import sys, os #Mocking uninstalled modules: https://read-the-docs.readthedocs.org/en/latest/faq.html -############################################################################## -## -## Mock out imports with C dependencies because ReadTheDocs can't build them. class Mock(object): + __all__ = [] def __init__(self, *args, **kwargs): - pass + for key, value in kwargs.iteritems(): + setattr(self, key, value) def __call__(self, *args, **kwargs): return Mock() - @classmethod - def __getattr__(cls, name): + __add__ = __mul__ = __getitem__ = __setitem__ = \ +__delitem__ = __sub__ = __floordiv__ = __mod__ = __divmod__ = \ +__pow__ = __lshift__ = __rshift__ = __and__ = __xor__ = __or__ = \ +__rmul__ = __rsub__ = __rfloordiv__ = __rmod__ = __rdivmod__ = \ +__rpow__ = __rlshift__ = __rrshift__ = __rand__ = __rxor__ = __ror__ = \ +__imul__ = __isub__ = __ifloordiv__ = __imod__ = __idivmod__ = \ +__ipow__ = __ilshift__ = __irshift__ = __iand__ = __ixor__ = __ior__ = \ +__neg__ = __pos__ = __abs__ = __invert__ = __call__ + + def __getattr__(self, name): if name in ('__file__', '__path__'): return '/dev/null' - elif name[0] == name[0].upper(): - mockType = type(name, (), {}) - mockType.__module__ = __name__ - return mockType + if name == 'sqrt': + return math.sqrt + elif name[0] != '_' and name[0] == name[0].upper(): + return type(name, (), {}) else: - return Mock() + return Mock(**vars(self)) -MOCK_MODULES = ['matplotlib', 'matplotlib.color', 'matplotlib.pyplot', 'pylab' ] + def __lt__(self, *args, **kwargs): + return True + + __nonzero__ = __le__ = __eq__ = __ne__ = __gt__ = __ge__ = __contains__ = \ +__lt__ + + + def __repr__(self): + # Use _mock_repr to fake the __repr__ call + res = getattr(self, "_mock_repr") + return res if isinstance(res, str) else "Mock" + + def __hash__(self): + return 1 + + __len__ = __int__ = __long__ = __index__ = __hash__ + + def __oct__(self): + return '01' + + def __hex__(self): + return '0x1' + + def __float__(self): + return 0.1 + + def __complex__(self): + return 1j + + +MOCK_MODULES = [ + 'pylab', 'scipy', 'matplotlib', 'matplotlib.pyplot', 'pyfits', + 'scipy.constants.constants', 'matplotlib.cm', + 'matplotlib.image', 'matplotlib.colors', 'sunpy.cm', + 'pandas', 'pandas.io', 'pandas.io.parsers', + 'suds', 'matplotlib.ticker', 'matplotlib.colorbar', + 'matplotlib.dates', 'scipy.optimize', 'scipy.ndimage', + 'matplotlib.figure', 'scipy.ndimage.interpolation', 'bs4'] for mod_name in MOCK_MODULES: - sys.modules[mod_name] = Mock() + sys.modules[mod_name] = Mock(pi=math.pi, G=6.67364e-11) + +sys.modules['numpy'] = Mock(pi=math.pi, G=6.67364e-11, + ndarray=type('ndarray', (), {}), + dtype=lambda _: Mock(_mock_repr='np.dtype(\'float32\')')) +sys.modules['scipy.constants'] = Mock(pi=math.pi, G=6.67364e-11) + +############################################################################## +## +## Mock out imports with C dependencies because ReadTheDocs can't build them. +#class Mock(object): + #def __init__(self, *args, **kwargs): + #pass + + #def __call__(self, *args, **kwargs): + #return Mock() + + #@classmethod + #def __getattr__(cls, name): + #if name in ('__file__', '__path__'): + #return '/dev/null' + #elif name[0] == name[0].upper(): + #mockType = type(name, (), {}) + #mockType.__module__ = __name__ + #return mockType + #else: + #return Mock() + +#MOCK_MODULES = ['pylab']#'matplotlib', 'matplotlib.color', 'matplotlib.pyplot', 'pylab' ] +#for mod_name in MOCK_MODULES: + #sys.modules[mod_name] = Mock() # 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 From a8120bd0157b68a63886049f8a9e430545bd91af Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 12:56:33 +0000 Subject: [PATCH 25/26] Testing differen mock --- doc/conf.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index a49a0c53..a24df189 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -82,12 +82,13 @@ MOCK_MODULES = [ 'matplotlib.dates', 'scipy.optimize', 'scipy.ndimage', 'matplotlib.figure', 'scipy.ndimage.interpolation', 'bs4'] for mod_name in MOCK_MODULES: - sys.modules[mod_name] = Mock(pi=math.pi, G=6.67364e-11) + sys.modules[mod_name] = Mock() -sys.modules['numpy'] = Mock(pi=math.pi, G=6.67364e-11, - ndarray=type('ndarray', (), {}), - dtype=lambda _: Mock(_mock_repr='np.dtype(\'float32\')')) -sys.modules['scipy.constants'] = Mock(pi=math.pi, G=6.67364e-11) + +#sys.modules['numpy'] = Mock(pi=math.pi, G=6.67364e-11, + #ndarray=type('ndarray', (), {}), + #dtype=lambda _: Mock(_mock_repr='np.dtype(\'float32\')')) +#sys.modules['scipy.constants'] = Mock(pi=math.pi, G=6.67364e-11) ############################################################################## ## From 021c429720f80925187b5cf0ab2bcdd8baa7b7d1 Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Thu, 31 Jan 2013 13:01:56 +0000 Subject: [PATCH 26/26] More --- doc/conf.py | 114 ++++++++++++++++++++++++++-------------------------- 1 file changed, 58 insertions(+), 56 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index a24df189..d32c77f7 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -15,74 +15,74 @@ import sys, os #Mocking uninstalled modules: https://read-the-docs.readthedocs.org/en/latest/faq.html -class Mock(object): - __all__ = [] - def __init__(self, *args, **kwargs): - for key, value in kwargs.iteritems(): - setattr(self, key, value) +#class Mock(object): + #__all__ = [] + #def __init__(self, *args, **kwargs): + #for key, value in kwargs.iteritems(): + #setattr(self, key, value) - def __call__(self, *args, **kwargs): - return Mock() + #def __call__(self, *args, **kwargs): + #return Mock() - __add__ = __mul__ = __getitem__ = __setitem__ = \ -__delitem__ = __sub__ = __floordiv__ = __mod__ = __divmod__ = \ -__pow__ = __lshift__ = __rshift__ = __and__ = __xor__ = __or__ = \ -__rmul__ = __rsub__ = __rfloordiv__ = __rmod__ = __rdivmod__ = \ -__rpow__ = __rlshift__ = __rrshift__ = __rand__ = __rxor__ = __ror__ = \ -__imul__ = __isub__ = __ifloordiv__ = __imod__ = __idivmod__ = \ -__ipow__ = __ilshift__ = __irshift__ = __iand__ = __ixor__ = __ior__ = \ -__neg__ = __pos__ = __abs__ = __invert__ = __call__ + #__add__ = __mul__ = __getitem__ = __setitem__ = \ +#__delitem__ = __sub__ = __floordiv__ = __mod__ = __divmod__ = \ +#__pow__ = __lshift__ = __rshift__ = __and__ = __xor__ = __or__ = \ +#__rmul__ = __rsub__ = __rfloordiv__ = __rmod__ = __rdivmod__ = \ +#__rpow__ = __rlshift__ = __rrshift__ = __rand__ = __rxor__ = __ror__ = \ +#__imul__ = __isub__ = __ifloordiv__ = __imod__ = __idivmod__ = \ +#__ipow__ = __ilshift__ = __irshift__ = __iand__ = __ixor__ = __ior__ = \ +#__neg__ = __pos__ = __abs__ = __invert__ = __call__ - def __getattr__(self, name): - if name in ('__file__', '__path__'): - return '/dev/null' - if name == 'sqrt': - return math.sqrt - elif name[0] != '_' and name[0] == name[0].upper(): - return type(name, (), {}) - else: - return Mock(**vars(self)) + #def __getattr__(self, name): + #if name in ('__file__', '__path__'): + #return '/dev/null' + #if name == 'sqrt': + #return math.sqrt + #elif name[0] != '_' and name[0] == name[0].upper(): + #return type(name, (), {}) + #else: + #return Mock(**vars(self)) - def __lt__(self, *args, **kwargs): - return True + #def __lt__(self, *args, **kwargs): + #return True - __nonzero__ = __le__ = __eq__ = __ne__ = __gt__ = __ge__ = __contains__ = \ -__lt__ + #__nonzero__ = __le__ = __eq__ = __ne__ = __gt__ = __ge__ = __contains__ = \ +#__lt__ - def __repr__(self): - # Use _mock_repr to fake the __repr__ call - res = getattr(self, "_mock_repr") - return res if isinstance(res, str) else "Mock" + #def __repr__(self): + ## Use _mock_repr to fake the __repr__ call + #res = getattr(self, "_mock_repr") + #return res if isinstance(res, str) else "Mock" - def __hash__(self): - return 1 + #def __hash__(self): + #return 1 - __len__ = __int__ = __long__ = __index__ = __hash__ + #__len__ = __int__ = __long__ = __index__ = __hash__ - def __oct__(self): - return '01' + #def __oct__(self): + #return '01' - def __hex__(self): - return '0x1' + #def __hex__(self): + #return '0x1' - def __float__(self): - return 0.1 + #def __float__(self): + #return 0.1 - def __complex__(self): - return 1j + #def __complex__(self): + #return 1j -MOCK_MODULES = [ - 'pylab', 'scipy', 'matplotlib', 'matplotlib.pyplot', 'pyfits', - 'scipy.constants.constants', 'matplotlib.cm', - 'matplotlib.image', 'matplotlib.colors', 'sunpy.cm', - 'pandas', 'pandas.io', 'pandas.io.parsers', - 'suds', 'matplotlib.ticker', 'matplotlib.colorbar', - 'matplotlib.dates', 'scipy.optimize', 'scipy.ndimage', - 'matplotlib.figure', 'scipy.ndimage.interpolation', 'bs4'] -for mod_name in MOCK_MODULES: - sys.modules[mod_name] = Mock() +#MOCK_MODULES = [ + #'pylab', 'scipy', 'matplotlib', 'matplotlib.pyplot', 'pyfits', + #'scipy.constants.constants', 'matplotlib.cm', + #'matplotlib.image', 'matplotlib.colors', 'sunpy.cm', + #'pandas', 'pandas.io', 'pandas.io.parsers', + #'suds', 'matplotlib.ticker', 'matplotlib.colorbar', + #'matplotlib.dates', 'scipy.optimize', 'scipy.ndimage', + #'matplotlib.figure', 'scipy.ndimage.interpolation', 'bs4'] +#for mod_name in MOCK_MODULES: + #sys.modules[mod_name] = Mock() #sys.modules['numpy'] = Mock(pi=math.pi, G=6.67364e-11, @@ -111,9 +111,11 @@ for mod_name in MOCK_MODULES: #else: #return Mock() -#MOCK_MODULES = ['pylab']#'matplotlib', 'matplotlib.color', 'matplotlib.pyplot', 'pylab' ] -#for mod_name in MOCK_MODULES: - #sys.modules[mod_name] = Mock() +import mock + +MOCK_MODULES = ['pylab', 'matplotlib']#'matplotlib', 'matplotlib.color', 'matplotlib.pyplot', 'pylab' ] +for mod_name in MOCK_MODULES: + sys.modules[mod_name] = mock.Mock() # 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