Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

implementation of mpl_init mechanism#30742

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
fecrescencio22 wants to merge2 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromfecrescencio22:refactor-for-issue-29813

Conversation

@fecrescencio22
Copy link

PR summary

Implementing the mpl_init mechanism to avoid dependency, as described in the discussion of issue#29813. Additionally, some tests are implemented.
Is a documentation update necessary?


# Initialize colormap registry (depends on rcParams['image.lut'])
frommatplotlibimportcm
ifhasattr(cm,'_mpl_init'):
Copy link
Member

Choose a reason for hiding this comment

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

We do not need conditionals on modules we control.


# workaround: we must defer colormaps import to after loading rcParams, because
# colormap creation depends on rcParams
# Import colormap registries (they are now safely initialized via _mpl_init())
Copy link
Member

Choose a reason for hiding this comment

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

If this is the case, can we move these imports to the top?

Copy link
Member

Choose a reason for hiding this comment

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

I guess we should move the imports to the top and replace these lines with creating aliases?



def_gen_cmap_registry():
def_gen_cmap_registry(lutsize):
Copy link
Member

Choose a reason for hiding this comment

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

If we are going to update the global anyway why change this function?

"""
program= (
"import matplotlib; "
"import matplotlib.cm as cm; "
Copy link
Member

Choose a reason for hiding this comment

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

This import order currently works, can you explain a bit more exactly what this is testing?matplotlib.cm is imported inmatplotilb/__init__.py so this import never actually triggers the import.



# Run submodule initialization after rcParams are loaded
_run_submodule_inits()
Copy link
Member

Choose a reason for hiding this comment

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

might as well put this almost at the bottom? The thing in particular that gets us in trouble is that if we access an attribute onmatplotlib in a sub-module before we have created it.rcParams is the most common problem (and the problem here) but we should cover the (more) general case and put this call as late as possible.

timhoffm reacted with thumbs up emoji
_bivar_colormaps=ColormapRegistry(bivar_cmaps)


def_ensure_cmap(cmap):
Copy link
Member

Choose a reason for hiding this comment

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

Why was this added?

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

Reviewers

@tacaswelltacaswelltacaswell left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[MNT]: Cleanup internal import dependencies and initialization logic

2 participants

@fecrescencio22@tacaswell

[8]ページ先頭

©2009-2025 Movatter.jp