Skip to content

Port examples to sphinx_gallery #170

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

Merged
merged 11 commits into from
Apr 6, 2023
Merged

Port examples to sphinx_gallery #170

merged 11 commits into from
Apr 6, 2023

Conversation

PicoCentauri
Copy link
Collaborator

Fixes #167

As already stated in the issue this will allow easier maintance and gives these nice gallery view:

Screenshot 2023-03-25 at 10 30 47

Also i fixed some warnings when generating the docs.

@PicoCentauri PicoCentauri force-pushed the sphinx_gallery branch 3 times, most recently from 58332eb to b3c2039 Compare March 25, 2023 10:01
@PicoCentauri
Copy link
Collaborator Author

PicoCentauri commented Mar 25, 2023

Somebody can help me with the linter? I ran black locally but still got an error in the ci...

EDIT: Should be fixed. My local version of black was not up to date.

@PicoCentauri PicoCentauri force-pushed the sphinx_gallery branch 8 times, most recently from d836803 to 5a5ad37 Compare March 27, 2023 09:45
@PicoCentauri
Copy link
Collaborator Author

I just saw that we can even use jupyterlite allowing running the examples in the browser. Should we try this?

Copy link
Collaborator

@rosecers rosecers left a comment

Choose a reason for hiding this comment

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

Overall this looks nice, but I caught a few conversion artifacts here and there. I have two other issues that should be ameliorated before merge --

  1. Ordering of the gallery -- we previously had the examples in a specific order, can we preserve this for the gallery?
  2. Sidebar contains all sub-headers, and should not.

I've built the docs at https://scikit-matter.readthedocs.io/en/sphinx_gallery/index.html if you'd like to see.


# %%
#
# Scale and Center the Features and Targets
Copy link
Collaborator

Choose a reason for hiding this comment

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

We've lost the relative importance of each header, can you fix it so that they are stacked like this?

  • Feature Selection on the WHO Dataset
    • Load the Dataset
      • Scale and Center the Features and Targets
      • Provide an estimated target for the feature selector
    • Compute the Selections for Each Selector Type
      • PCov-CUR
      • PCov-FPS
      • CUR
      • FPS
      • (For Comparison) Recursive Feature Addition
    • Plot our Results

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should be done in the latest version.


# %%
#
# (For Comparison) Recurisive Feature Addition
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# (For Comparison) Recurisive Feature Addition
# (For Comparison) Recursive Feature Addition


plt.legend(bbox_to_anchor=(1, 1), loc="upper left")

plt.show()
Copy link
Collaborator

Choose a reason for hiding this comment

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

This figure is cut off in the build.

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should be done.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Now it looks all messed up
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ohh this looks nice 🤣.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Lets see how this looks in the new commit.

)
ax_wo_orth.set_xlabel("scaling in z direction")
ax_wo_orth.legend(loc="upper right", bbox_to_anchor=(0.7, -0.2))
plt.show()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same with this one...

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should be done.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here:
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Lets see how this looks in the new commit.


# %%
#
# load features
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same issue as last example


# %%
#
# load features
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as last two

# \exp(-\gamma \|\mathbf{x}-\mathbf{x}'\|^2),\quad \gamma\in\mathbb{R}_+
#
# The projected RKHS features are computed using the eigendecomposition of the
# positive-definite kernel matrix :math:`K``
Copy link
Collaborator

Choose a reason for hiding this comment

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

prime mark is misplaced

@rosecers
Copy link
Collaborator

I just saw that we can even use jupyterlite allowing running the examples in the browser. Should we try this?

Feel free to put in an issue, I think that'd be great!

@PicoCentauri
Copy link
Collaborator Author

Thanks for the feedback. I will see what I can do.

Manual ordering always works.

@PicoCentauri
Copy link
Collaborator Author

I've built the docs at https://scikit-matter.readthedocs.io/en/sphinx_gallery/index.html if you'd like to see.

Thanks but you don't have to enable this manually the next time. In #161 we enabled that RTD builds the docs for each PR. For this one it is here: https://scikit-matter--170.org.readthedocs.build/en/170/. I will add a GH action in #172 for a direct link.

@PicoCentauri PicoCentauri force-pushed the sphinx_gallery branch 2 times, most recently from 6e6b9a8 to 9cf0239 Compare March 28, 2023 07:32
@PicoCentauri PicoCentauri force-pushed the sphinx_gallery branch 3 times, most recently from 8bb6c36 to 81a67bd Compare March 29, 2023 11:14
@victorprincipe
Copy link
Collaborator

Just went through the examples and made some typo/formatting fixes. Rest looks good.

@PicoCentauri PicoCentauri force-pushed the sphinx_gallery branch 2 times, most recently from f1aa078 to 6834940 Compare March 30, 2023 16:09
@PicoCentauri
Copy link
Collaborator Author

Thanks @victorprincipe. All of them are super useful changes. I fixed another tiny formatting thing.

@ceriottm
Copy link
Collaborator

ceriottm commented Apr 3, 2023

I don't see the nice gallery on the auto-built readthedocs page at https://scikit-matter--170.org.readthedocs.build/en/170/tutorials.html#

@PicoCentauri
Copy link
Collaborator Author

I don't see the nice gallery on the auto-built readthedocs page at https://scikit-matter--170.org.readthedocs.build/en/170/tutorials.html#

I had to remove the gallery view in order to keep the same structure as it was before. Sorry, if we want to have the gallery back I can look later how we can order it. But I think it will be not super easy to maintain the section titles.

@ceriottm
Copy link
Collaborator

ceriottm commented Apr 4, 2023

Bummer. The gallery was really pretty.

@PicoCentauri
Copy link
Collaborator Author

Yes, I was also a fan of it.

@rosecers
Copy link
Collaborator

rosecers commented Apr 4, 2023 via email

@PicoCentauri
Copy link
Collaborator Author

The only way I see is that we do subfolders for each current section and then we use sub-gallery-order.

@PicoCentauri
Copy link
Collaborator Author

Galleries are back. Let me know @rosecers and @ceriottm if this fine for you.

@ceriottm
Copy link
Collaborator

ceriottm commented Apr 6, 2023

I like it a lot - it's also better to have separate pages, and I was finding the list of sub-headings of the notebooks rather confusing. IMO this is good to go.

@rosecers rosecers self-requested a review April 6, 2023 20:54
Copy link
Collaborator

@rosecers rosecers left a comment

Choose a reason for hiding this comment

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

Looks good! Please squash before merging.

@PicoCentauri PicoCentauri merged commit 89073a9 into main Apr 6, 2023
@PicoCentauri PicoCentauri deleted the sphinx_gallery branch April 6, 2023 21:22
@PicoCentauri
Copy link
Collaborator Author

Thanks for your feedback! I can help you with rebasing your PR @ceriottm

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.

Move notebooks to sphinx gallery python scripts
4 participants