unitaryfund / mitiq

Mitiq is an open source toolkit for implementing error mitigation techniques on most current intermediate-scale quantum computers.
https://mitiq.readthedocs.io
GNU General Public License v3.0
344 stars 145 forks source link

Add download notebook link in docs #2363

Closed cosenal closed 1 month ago

cosenal commented 1 month ago

Fixes #1619.

For a demo, see https://mitiq--2363.org.readthedocs.build/en/2363/examples/calibration-tutorial.html

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 98.22%. Comparing base (2a41ad0) to head (7ea42ff).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2363 +/- ## ======================================= Coverage 98.22% 98.22% ======================================= Files 87 87 Lines 4059 4059 ======================================= Hits 3987 3987 Misses 72 72 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

jordandsullivan commented 1 month ago

Nice! Thanks for implementing this. One thing I noticed is that it doesn't include the images referenced in the notebook, so for the example you link:

For a demo, see https://mitiq--2363.org.readthedocs.build/en/2363/examples/calibration-tutorial.html

The image at the top doesn't load. In this case it's no big deal since the image is basically just a thumbnail

Screen Shot 2024-05-13 at 10 42 44 AM Screen Shot 2024-05-13 at 10 40 30 AM

However, in cases where there's a diagram or figure included, it might be confusing to not have it missing.

Looking through a handful of examples though, e.g. (layerwise folding, Pennylane, it seems like the vast majority of images that are included in these docs are generated by the code itself, e.g.

Screen Shot 2024-05-13 at 10 49 24 AM

from the PennyLane example, so I don't see this as a blocking issue.

cosenal commented 1 month ago

@jordandsullivan I don't see any great solution for that. And in fact it's going to be the same in any implementation of the «Download notebook» if we want to export it as an .ipynb. Unless we overcomplicate it and package it as a zip with images included. Same problem with all implementations I saw around, for example see the notebook that you can download from Jupyter Book chapter: https://inferentialthinking.com/chapters/08/Functions_and_Tables.html

A solution could be to use absolute url for images, which are already in our repo. E.g. https://github.com/unitaryfund/mitiq/blob/main/docs/source/_thumbnails/calibration.png for your example.

jordandsullivan commented 1 month ago

@cosenal Yeah like I said, I think it's fine given that it seems relatively rare the images contain anything crucial in our notebooks.

andre-a-alves commented 1 month ago

Not to complicate things, but if we want to keep the images, we can always embed them as data directly in an <img> tag. I had to do it in a personal project before to keep images in Jupyter notebooks. We would just need to also document the need to do so when adding notebooks.

cosenal commented 1 month ago

@andre-a-alves that's an option too, but it will make the .md files more bulky and worse to review/edit.