Skip to content
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

Mayavi support #42

Merged
merged 4 commits into from Aug 4, 2015
Merged

Mayavi support #42

merged 4 commits into from Aug 4, 2015

Conversation

agramfort
Copy link
Contributor

patch to add mayavi support on top of #36

@agramfort
Copy link
Contributor Author

@Titan-C we're making progress here.

Can you have a look?

So far for us the images are moved to the bottom which is weird but besides this it works great.

@Titan-C
Copy link
Member

Titan-C commented Jul 14, 2015

Can you have a look?

It looks ok. I would add a short example to show a plot in mayavi.
Also to make the test in travis pass one has to put mayavi in the requirements.txt file to install it.

So far for us the images are moved to the bottom which is weird but besides this it works great.

Do you mean bottom miss aligned? or bottom shown after the code? Because as part of adopting the notebook layout I put the images after the code.

Are you doing the sprint during the holiday? I can go today.

@GaelVaroquaux
Copy link
Contributor

GaelVaroquaux commented Jul 14, 2015 via email

@agramfort
Copy link
Contributor Author

agramfort commented Jul 14, 2015 via email

@agramfort agramfort force-pushed the mayavi_support branch 4 times, most recently from e2b1f0d to 2a2f0d7 Compare July 15, 2015 08:18
@larsoner
Copy link
Contributor

Travis is happy now

@larsoner
Copy link
Contributor

FYI I added the raise_gallery option, which makes it possible to have it raise errors as it encounters them in doc building, which we have found useful

@agramfort
Copy link
Contributor Author

let's wait for the PR to be merged.

@larsoner
Copy link
Contributor

I did it as part of the commit that made Travis happy. Do you want me to undo the commit and split it up?

@larsoner
Copy link
Contributor

Just a reminder at some point we also need to add support for plot_gallery=fast command-line option, which will make it skip examples marked as slow

@agramfort
Copy link
Contributor Author

agramfort commented Jul 17, 2015 via email

@lesteve
Copy link
Member

lesteve commented Jul 31, 2015

#36 has been merged now and you need to rebase it seems like.

@agramfort
Copy link
Contributor Author

Yeah will do today

On 31 juil. 2015, at 09:37, Loïc Estève notifications@github.com wrote:

#36 has been merged now and you need to rebase it seems like.


Reply to this email directly or view it on GitHub.

@agramfort agramfort force-pushed the mayavi_support branch 2 times, most recently from 6c1b335 to 73f1512 Compare July 31, 2015 12:08
@agramfort
Copy link
Contributor Author

rebased and travis is happy. Ready for review

try:
from mayavi import mlab
use_mayavi = True
except ImportError, e:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not python 3 compatible and is old way of doing things in python 2. Slightly annoying that the tests pass, but oh well this is part of the doc generation and not really the sphinxgallery package ...

Since you are not using the exception you might as well just do:

except ImportError:

@agramfort
Copy link
Contributor Author

comments addressed.

@agramfort
Copy link
Contributor Author

any more comment?

@agramfort
Copy link
Contributor Author

done

@@ -22,6 +22,7 @@ Contents:
reference
auto_examples/index
tutorials/index
auto_mayavi_examples/index
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but now this link will not exist unless mayavi is present... maybe it's just a sphinx warning so no big deal...

@lesteve lesteve mentioned this pull request Aug 4, 2015
@@ -409,6 +409,8 @@ def embed_code_links(app, exception):
"""Embed hyperlinks to documentation into example code"""
if exception is not None:
return
if not app.builder.config.plot_gallery:
return # no need to embed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed that in my previous reviews. Why don't you want to put hyperlinks inside the example in case plot_gallery is False? Is it because it can fail if there is a parsing error of the script ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

On 4 août 2015, at 09:35, Loïc Estève notifications@github.com wrote:

In sphinxgallery/docs_resolv.py:

@@ -409,6 +409,8 @@ def embed_code_links(app, exception):
"""Embed hyperlinks to documentation into example code"""
if exception is not None:
return

  • if not app.builder.config.plot_gallery:
  •    return  # no need to embed
    
    I missed that in my previous reviews. Why don't you want to put hyperlinks inside the example in case plot_gallery is False? Is it because it can fail if there is a parsing error of the script ?


Reply to this email directly or view it on GitHub.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then could you improve the comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also because when writing narrative doc you don't want to plot and wait for all the embedding

On 4 août 2015, at 09:35, Loïc Estève notifications@github.com wrote:

In sphinxgallery/docs_resolv.py:

@@ -409,6 +409,8 @@ def embed_code_links(app, exception):
"""Embed hyperlinks to documentation into example code"""
if exception is not None:
return

  • if not app.builder.config.plot_gallery:
  •    return  # no need to embed
    
    I missed that in my previous reviews. Why don't you want to put hyperlinks inside the example in case plot_gallery is False? Is it because it can fail if there is a parsing error of the script ?


Reply to this email directly or view it on GitHub.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lesteve
Copy link
Member

lesteve commented Aug 4, 2015

Just curious, is there a way to do the equivalent of matplotlib.use('Agg') so that the mayavi figures don't pop up while generating the doc?

@GaelVaroquaux
Copy link
Contributor

Just curious, is there a way to do the equivalent of matplotlib.use('Agg') so
that the mayavi figures don't pop up while generating the doc?

You want to set the mlab enfine as the offscreenengine.

http://docs.enthought.com/mayavi/mayavi/auto/example_offscreen.html

This should be easily done by the following:

from mayavi import mlab
mlab.options.offscreen = True

@lesteve
Copy link
Member

lesteve commented Aug 4, 2015

OK I just tried to generate the doc with the mayavi example and I got an error that the MNE-Python people know about ... mne-tools/mne-python#2062.

The last comment on the issue seems to indicate that it works with pyface master, but is there any better option?

For completeness I installed mayavi through Anaconda.

For reference, here is the log from sphinx:

# Sphinx version: 1.3.1
# Python version: 2.7.10 (CPython)
# Docutils version: 0.12 release
# Jinja2 version: 2.8
# Last messages:
#   pickling environment...
#   done
#   checking consistency...
#   done
#   preparing documents...
#   done
#   writing output... [  5%] advanced_configuration
#   writing output... [ 11%] auto_examples/index
#   writing output... [ 17%] auto_examples/just_code
#   writing output... [ 23%] auto_examples/plot_gallery_version
# Loaded extensions:
#   sphinx.ext.autodoc (1.3.1) from /volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg/sphin
#   sphinx.ext.intersphinx (1.3.1) from /volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg/s
#   sphinx.ext.doctest (1.3.1) from /volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg/sphin
#   sphinx.ext.mathjax (1.3.1) from /volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg/sphin
#   sphinx.ext.coverage (1.3.1) from /volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg/sphi
#   sphinx.ext.todo (1.3.1) from /volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg/sphinx/e
#   alabaster (0.7.3) from /volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/alabaster/__init__.pyc
#   sphinxgallery.gen_gallery (unknown version) from /home/le243287/dev/sphinx-gallery/sphinxgallery/gen_gallery.pyc
Traceback (most recent call last):
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg/sphinx/cmdline.py", line 245, in 
    app.build(opts.force_all, filenames)
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg/sphinx/application.py", line 264,
    self.builder.build_update()
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg/sphinx/builders/__init__.py", lin
    'out of date' % len(to_build))
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg/sphinx/builders/__init__.py", lin
    self.write(docnames, list(updated_docnames), method)
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg/sphinx/builders/__init__.py", lin
    self._write_serial(sorted(docnames), warnings)
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg/sphinx/builders/__init__.py", lin
    self.write_doc(docname, doctree)
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg/sphinx/builders/html.py", line 43
    self.docwriter.write(doctree, destination)
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/docutils/writers/__init__.py", line 80, in write
    self.translate()
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg/sphinx/writers/html.py", line 53,
    self.document.walkabout(visitor)
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/docutils/nodes.py", line 174, in walkabout
    if child.walkabout(visitor):
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/docutils/nodes.py", line 174, in walkabout
    if child.walkabout(visitor):
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/docutils/nodes.py", line 166, in walkabout
    visitor.dispatch_visit(self)
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/docutils/nodes.py", line 1882, in dispatch_visit
    return method(node)
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg/sphinx/writers/html.py", line 720
    HTMLTranslator.visit_literal_block(self, node)
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg/sphinx/writers/html.py", line 331
    **highlight_args)
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg/sphinx/highlighting.py", line 185
    hlsource = highlight(source, lexer, formatter)
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/pygments/__init__.py", line 87, in highlight
    return format(lex(code, lexer), formatter, outfile)
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/pygments/__init__.py", line 66, in format
    formatter.format(tokens, realoutfile)
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/pygments/formatter.py", line 95, in format
    return self.format_unencoded(tokensource, outfile)
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/pygments/formatters/html.py", line 838, in format_unenco
    for t, piece in source:
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/pygments/formatters/html.py", line 684, in _wrap_div
    for tup in inner:
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/pygments/formatters/html.py", line 697, in _wrap_pre
    for tup in inner:
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/pygments/formatters/html.py", line 716, in _format_lines
    for ttype, value in tokensource:
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/pygments/filter.py", line 20, in _apply
    for token in filter_.filter(lexer, stream):
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/pygments/filters/__init__.py", line 194, in filter
    for ttype, value in stream:
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/pygments/lexer.py", line 192, in streamer
    for i, t, v in self.get_tokens_unprocessed(text):
  File "/volatile/le243287/miniconda3/envs/mayavi/lib/python2.7/site-packages/pyface/ui/qt4/code_editor/pygments_highlighter.py", line
    for item in action(self, m):
TypeError: 'NoneType' object is not callable

@agramfort
Copy link
Contributor Author

agramfort commented Aug 4, 2015 via email

@GaelVaroquaux
Copy link
Contributor

GaelVaroquaux commented Aug 4, 2015 via email

@lesteve
Copy link
Member

lesteve commented Aug 4, 2015

For completeness, pyface original issue (fixed in master) enthought/pyface#113.

@lesteve
Copy link
Member

lesteve commented Aug 4, 2015

You don't actually need pyface master, pip install pyface fixed it for me.

It's just that the version provided by conda is 4.4 which is from Dec 4, 2013 for some reason.

@agramfort
Copy link
Contributor Author

Cool

On 4 août 2015, at 11:16, Loïc Estève notifications@github.com wrote:

You don't actually need pyface master, pip install pyface fixed it for me.

It's just that the version provided by conda is 4.4 which is from Dec 4, 2013 for some reason.


Reply to this email directly or view it on GitHub.

@lesteve
Copy link
Member

lesteve commented Aug 4, 2015

@lesteve please take over. I am mostly on my phone these days. It will be faster if you do a cosmit on your side. Je te donne carte blanche :)

OK I'll merge that as is and patch it up myself.

lesteve added a commit that referenced this pull request Aug 4, 2015
@lesteve lesteve merged commit 9bbbc49 into sphinx-gallery:master Aug 4, 2015
@agramfort
Copy link
Contributor Author

agramfort commented Aug 4, 2015 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants