Skip to content

Conversation

@rossbar
Copy link
Collaborator

@rossbar rossbar commented Nov 12, 2025

To this point, numpy-tutorials made the policy decision to limit markup that wouldn't work within notebooks themselves. The Jupyter community generally seems to be moving towards better integrating MyST into the Jupyter ecosystem, and we certainly want to make use of/encourage these developments for richer scientific communication! Now that the jupyterlab_myst extension exists, markdown features beyond commonmark are supported in notebooks themselves.

This PR includes integration of 2 main features of MyST:

  1. Admonitions, and
  2. Exception rendering from cells that are expected to fail

I resisted the temptation to improve cross-linking as I don't think the underlying tooling is consistent across the JB1/JB2 boundary: JB1 allows us to make use of intersphinx, but the story in JB2 is not yet as clear.

The use of admonitions should be relatively unobjectionable as they are (IMO) now well-supported both in rendered outputs and in interactive notebooks (albeit requiring an extension [for now]). The execution skipping/exception rendering is more experimental as I suspect the testing tools are not fully up-to-speed to support it. Nevertheless it's a nice feature and something I think we should work towards ensuring is supported in the JB2 universe!

A minor note about the admonitions: the diffs make it look like content has changed but in practice the only thing that's different (aside from the admonitions themselves) is that I added linebreaks. We should look into adding a linter to handle line length, but that's a separate issue. If the added newlines are a blocker for adding admonitions I'm happy to back them out - just LMK!

@rossbar rossbar added the enhancement New feature or request label Nov 12, 2025
Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

I do like what I see so far.

Comment on lines +51 to +56
If you prefer, you can use your own image as you work through this tutorial.
In order to transform your image into a NumPy array that can be manipulated, you
can use the `imread` function from the
[matplotlib.pyplot](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.html#module-matplotlib.pyplot) submodule.
Alternatively, you can use the
[imageio.imread](https://imageio.readthedocs.io/en/stable/_autosummary/imageio.v3.imread.html)
function from the `imageio` library.
Be aware that if you use your own image, you'll likely need to adapt the steps below.
For more information on how images are treated when converted to NumPy arrays,
see [A crash course on NumPy for images](https://scikit-image.org/docs/stable/user_guide/numpy_images.html) from the `scikit-image` documentation.
Copy link
Member

Choose a reason for hiding this comment

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

I would recommend to follow standard(?) markdown style and put one sentence on one line. That would help with future review by limiting the diff.
(and if you think a line is way too long it would just nicely nudge you to cut it into two sentences :) )

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah ideally we find a linter to automagically enforce some reasonable line breaks, then update all the notebooks in one PR and add that commit to the .git-blame-ignore-revs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants