Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add explicit registration of units in examples #23508

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

Closed
wants to merge 1 commit into from

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Jul 28, 2022

PR Summary

Starting in sphinx-gallery/sphinx-gallery#890, sphinx-gallery started clearing Matplotlib's unit registry. But since basic_units was already imported, its register-on-import never happened for subsequent examples, breaking them.

PR Checklist

Tests and Styling

  • [n/a] Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • [n/a] New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • [n/a] API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

Starting in sphinx-gallery/sphinx-gallery#890,
sphinx-gallery started clearing Matplotlib's unit registry. But since
`basic_units` was already imported, its register-on-import never
happened for subsequent examples, breaking them.
@@ -380,4 +380,17 @@ def cos(x):
return math.cos(x.convert_to(radians).get_value())


units.registry[BasicUnit] = units.registry[TaggedValue] = BasicUnitConverter()
def register_units():
Copy link
Member

Choose a reason for hiding this comment

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

I'm still a little tan about who is incorrect here. It really seems sphinx gallery should spawn a new process for each example so the import happens again. However, I can see why that would be slow. It does make me extremely suspicious about changing behaviour via a registry that gets set at import time like this... (and yes we do it internally for dates and categorical as well).

Copy link
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

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

@tacaswell tacaswell mentioned this pull request Jul 29, 2022
1 task
@QuLogic
Copy link
Member Author

QuLogic commented Jul 30, 2022

Replaced by #23514.

@QuLogic QuLogic closed this Jul 30, 2022
@QuLogic QuLogic deleted the fix-docs branch July 30, 2022 00:24
@QuLogic QuLogic modified the milestones: v3.5.3, unassigned Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants