Navigation Menu

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

Make template gallery #499

Merged
merged 39 commits into from Feb 16, 2020
Merged

Make template gallery #499

merged 39 commits into from Feb 16, 2020

Conversation

mariaschuld
Copy link
Contributor

@mariaschuld mariaschuld commented Feb 6, 2020

Context:

The templates.rst file was outdated and needed the latest templates to be added. In the process I turned tables into a gallery, which is much more appealing.

Description of the Change:

Add custom directives for gallery items and turn tables into gallery.

Results only affect this tab:

Screenshot from 2020-02-06 12-15-21

Here is a sneak peak:

Screenshot from 2020-02-06 12-15-05
Screenshot from 2020-02-06 12-15-08
Screenshot from 2020-02-06 12-15-16

Benefits: User gets an idea of what the templates are on first glance.

Possible Drawbacks: We should make the gallery thumbnails wider to have less white space?

Related GitHub Issues: -

doc/conf.py Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Feb 6, 2020

Codecov Report

Merging #499 into master will increase coverage by 0.12%.
The diff coverage is 76.19%.

@@            Coverage Diff             @@
##           master     #499      +/-   ##
==========================================
+ Coverage   98.89%   99.01%   +0.12%     
==========================================
  Files          74       71       -3     
  Lines        4695     4561     -134     
==========================================
- Hits         4643     4516     -127     
+ Misses         52       45       -7
Impacted Files Coverage Δ
pennylane/qnodes/passthru.py 88.88% <0%> (+1.79%) ⬆️
pennylane/qnodes/base.py 100% <100%> (ø) ⬆️
pennylane/beta/__init__.py 100% <0%> (ø) ⬆️
pennylane/beta/plugins/__init__.py 100% <0%> (ø) ⬆️
pennylane/beta/plugins/default_tensor.py 95.9% <0%> (ø) ⬆️
pennylane/beta/plugins/default_tensor_tf.py 92.17% <0%> (ø) ⬆️
pennylane/interfaces/tf.py 89.13% <0%> (ø) ⬆️
pennylane/qnodes/device_jacobian.py 90.9% <0%> (ø) ⬆️
pennylane/collections/sum.py 100% <0%> (ø) ⬆️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 712b05b...d41f18c. Read the comment docs.

@mariaschuld mariaschuld self-assigned this Feb 6, 2020
@mariaschuld mariaschuld added documentation 📘 Documentation changes and updates review-ready 👌 PRs which are ready for review by someone from the core team. labels Feb 6, 2020
Copy link
Member

@josh146 josh146 left a comment

Choose a reason for hiding this comment

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

This is really beautiful, I love it!

Note, when I build the docs, I get the following errors:

/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/embeddings/amplitude.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/embeddings/angle.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/embeddings/basis.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/embeddings/displacement.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/embeddings/qaoa.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/embeddings/squeezing.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/layers/cvqnn.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/layers/random.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/layers/strongly_entangling.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/state_preparations/basis.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/state_preparations/mottonen.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/subroutines/interferometer.png

An issue with the path? Note that if you instead do /_static, sphinx treats this as an absolute path starting from the doc folder (avoiding relative path headaches).

However, I notice now that I can't see these 'failed' images anywhere, everything seems to be working...

doc/conf.py Show resolved Hide resolved
doc/conf.py Show resolved Hide resolved
doc/directives.py Outdated Show resolved Hide resolved
doc/directives.py Outdated Show resolved Hide resolved
doc/introduction/templates.rst Show resolved Hide resolved
Copy link
Contributor

@antalszava antalszava left a comment

Choose a reason for hiding this comment

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

From my side it looks really amazing @mariaschuld ! :) Once the other comments are also addressed, I have no further objections. This makes the template library really attractive for users browsing the site

@mariaschuld
Copy link
Contributor Author

This is really beautiful, I love it!

Note, when I build the docs, I get the following errors:

/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/embeddings/amplitude.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/embeddings/angle.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/embeddings/basis.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/embeddings/displacement.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/embeddings/qaoa.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/embeddings/squeezing.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/layers/cvqnn.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/layers/random.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/layers/strongly_entangling.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/state_preparations/basis.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/state_preparations/mottonen.png
/home/josh/Dropbox/Work/Xanadu/pennylane/doc/introduction/templates.rst:: WARNING: image file not readable: ../_static/templates/subroutines/interferometer.png

An issue with the path? Note that if you instead do /_static, sphinx treats this as an absolute path starting from the doc folder (avoiding relative path headaches).

However, I notice now that I can't see these 'failed' images anywhere, everything seems to be working...

I tried for hours and cannot figure out why sphinx is behaving this way. Other options for the path are also not working. Maybe related to this: sphinx-gallery/sphinx-gallery#120 ?

@josh146
Copy link
Member

josh146 commented Feb 10, 2020

I'll try and look into it today!

@mariaschuld
Copy link
Contributor Author

Runs without errors now, I used some code that was commented out in the walrus - I think sphinx takes images and saves them again in a reshaped/thumb version, which is the one it wants to import.

@mariaschuld
Copy link
Contributor Author

mariaschuld commented Feb 10, 2020

From my side the only item on my wishlist is to make the images in the gallery items larger. I managed to rescale the cards themselves to be wider, but I cannot enlarge the image.
This is what I tired:

  • use sphinx_gallery.gen_rst.scale_image -> nothing happens
  • use :width: in html template -> shifts and rescales in a very strange fashion
  • change css -> only affects container

I think it would be great if they fill the entire upper part, as in normal bootstrap cards:

image

@mariaschuld
Copy link
Contributor Author

Switched to cards and updated some pictures...

Looking much better now!

Screenshot from 2020-02-10 23-03-00

@josh146
Copy link
Member

josh146 commented Feb 10, 2020

Awesome! Couple of quick questions:

  • How does it deal with responsiveness? I.e. as you make the browser width smaller and smaller, does it scale properly?

  • Some of the cards seem taller than others?

I also like the new AmplitudeEmbedding diagram

@mariaschuld
Copy link
Contributor Author

Scaling works ok, the cards move into double and then single columns. The is a glitch though, it doesn't fill up the last row nicely:

Screenshot from 2020-02-11 16-48-04

Single column works well

Screenshot from 2020-02-11 16-49-09

As for the size, I can't see a difference between cards. Which one did you spot? Should be regulated by the picture size, which should be the same by design.

@josh146
Copy link
Member

josh146 commented Feb 13, 2020

The three layers seem very subtly different heights (e.g., the baseline of StrongEnt seems to be below that of RandomLayers). A height difference could also explain that missing hole when resizing the template cards

@mariaschuld
Copy link
Contributor Author

mariaschuld commented Feb 14, 2020

You were right @josh146. With the height and width of the image fixed the resizing problem disappears.

Screenshot from 2020-02-14 08-52-07

And this is the normal view:

Screenshot from 2020-02-14 08-52-24

<a href={link}>
<img class="card-img-top" src={thumbnail} alt="image not found">
<img class="card-img-top" src={thumbnail} alt="image not found" style="width: 13rem; height: 6rem;">
Copy link
Member

Choose a reason for hiding this comment

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

👍

@josh146 josh146 added merge-ready ✔️ All tests pass and the PR is ready to be merged. and removed review-ready 👌 PRs which are ready for review by someone from the core team. labels Feb 16, 2020
@mariaschuld mariaschuld merged commit c266f1a into master Feb 16, 2020
@mariaschuld mariaschuld deleted the make_template_gallery branch March 30, 2020 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation 📘 Documentation changes and updates merge-ready ✔️ All tests pass and the PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants