Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Binder jupytext#12116

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
mwouts wants to merge3 commits intomatplotlib:masterfrommwouts:binder_jupytext
Closed

Binder jupytext#12116

mwouts wants to merge3 commits intomatplotlib:masterfrommwouts:binder_jupytext

Conversation

mwouts
Copy link

The binder project and Jupytext can turn the matplotlib example library into a collection of interactive notebooks.

Try it now athttps://mybinder.org/v2/gh/mwouts/matplotlib/master?filepath=examples

Further work is apparently required on the examples themselves - not all plots are shown correctly in Jupyter (Is that a Jupyter configuration issue? Your probably know better than me).

image

@ImportanceOfBeingErnest
Copy link
Member

There is rather long discussion about making examples available for interactive use in
Adding Binder links to the Matplotlib gallery #11415 and
DOC: Add links to pyodide to examples #11670.

In contrast, the approach here would be to let binder generate notebooks from the example.py files, is that correct?

Here is the link to an introduction ofjupytext. And this is thejupytext github repo. Still, a little bit of explanation about how that plays together with binder would probably be welcome.

Attn.@choldgraf who initiated some of the earlier attempts for binder links via sphinx-gallery.

@ImportanceOfBeingErnest
Copy link
Member

not all plots are shown correctly in Jupyter

Comparing the notebooks generated via sphinx-gallery, which are downloadable below each example, and the ones generated via Jupytext is that Jupytext apperently triggers a new cell at each comment or double line break in the code, such that figures are not shown uponplt.show() in a later cell, while the sphinx-gallery-generated notebooks preserve the code in one cell.

image

@mwouts
Copy link
Author

Thanks! That's very helpful. I will also read the related discussions, they seem pretty interesting!

Jupytext is a plugin for Jupyter notebook that allows Jupyter to read/write notebooks directly from/to plain Python scripts. No ipynb file is generated in that process. Binder provides the Jupyter notebook, and the two seem to work well together.

Jupytext currently splits python files, when it reads them as a notebook, on blank lines (well, blank lines not inside functions, classes, etc). Clearly the current implementation does not seem to work well with the example above. Can you think of another approach (two blank lines??) that would work better (is there something like animplicit cell separator in the matplotlib examples)?

@jklymak
Copy link
Member

I think the same separators as rst are 95% of the time the appropriate ones (i..e a long line of#######). The comments directly below the separator are rendered as rst, and the code below as one cell.

@anntzer
Copy link
Contributor

anntzer commentedSep 14, 2018
edited
Loading

The approach I took for sphinx-exhibit (#11936) is to use toplevel strings as text cells (with the option to use sphinx-gallery's choice). I actually think this works well with the single-cell case (just a docstring):

"""this is a docstring"""some code"""more text"""more code

(ok it looks horrible without syntax highlighting and with a stupid example but I think you get the idea)

Here if you just want to separate two code blocks you could just put in a toplevel empty string ("" or """""") which is less a pain to type than 79x#...


Also, I guess(?) this will again choke on more complex rst constructs (cf the image tutorial example in the sphinx-exhibit thread) because I think they are basically unparseable without running them through sphinx. Now you may say oh well let's just switch everything to markdown but it's never going to be as expressive...

@mwouts
Copy link
Author

Thanks for the feedback! I'm new to RST, Sphynx, etc, but happy to learn. Let me come back in a few weeks with a proposal for another format in Jupytext that will better treat Sphynx oriented scripts (mwouts/jupytext#80)...

@tacaswelltacaswell added this to thev3.1 milestoneSep 15, 2018
@choldgraf
Copy link
Contributor

@mwouts check out sphinx-gallery for one way to do the python -> notebook conversion. I'd be (in theory) +1 on factoring out sphinx-gallery's conversion code into a standalone.py -> .ipynb module and then just depending on that within sphinx-gallery. It's always seemed like a useful enough thing to do on its own that it shouldn't be embedded in a gallery creation package.

mwouts reacted with thumbs up emoji

@mwouts
Copy link
Author

@choldgraf , thanks for the reference. I have started exploring the sphinx-gallery module, and I am doubting how to exactly implement the sphinx-gallery format for Jupytext (mwouts/jupytext#80).

Do you want to advice on whether I should include the RST to markdown conversion? I am asking as Jupytext offers, for the other formats, a solid round trip conversion (that allows to safely edit scripts from within Jupyter). Converting RST to markdown would break that - is it worth the nicer rendering?

@mwouts
Copy link
Author

Hello everyone. I have just published a new RC for Jupytext, which now has support for Sphinx-gallery scripts. Would you like to have a look at thematplotlib binder ? Documentation for that rc ishere. Thanks!

ImportanceOfBeingErnest reacted with thumbs up emoji

@choldgraf
Copy link
Contributor

very cool! thanks!

@jklymak
Copy link
Member

Closing for now. The binder links here give a TOC< but the actual examples don't seem to render, so I'll assume this is not working yet? But happy to re-open...

@jklymak
Copy link
Member

Ooops, my apologies - binder must have been having a hiccup. It seems to work now.

@jklymakjklymak reopened thisFeb 10, 2019
@jklymakjklymak modified the milestones:v3.1.0,v3.2.0Feb 11, 2019
@tacaswelltacaswell modified the milestones:v3.2.0,v3.3.0Aug 25, 2019
@QuLogicQuLogic modified the milestones:v3.3.0,v3.4.0May 2, 2020
@jklymak
Copy link
Member

I'll close this as not getting enough traction, but anyone should feel free to re-open (or request)

@QuLogicQuLogic removed this from thev3.4.0 milestoneMar 16, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

7 participants
@mwouts@ImportanceOfBeingErnest@jklymak@anntzer@choldgraf@tacaswell@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp