Skip to content

Fix make_norm_from_scale __name__ when used inline. - #21112

Merged
story645 merged 1 commit into
matplotlib:masterfrom
anntzer:mnfsn
Sep 19, 2021
Merged

story645 merged 1 commit into
matplotlib:masterfrom
anntzer:mnfsn

Conversation

@anntzer

@anntzer anntzer commented Sep 18, 2021

Copy link
Copy Markdown
Contributor

make_norm_from_scale can be used "inline", rather than as a class
decorator, to dynamically create norm classes. However, in that case,
the second parameter (base_norm_cls) would normally be set to the root
base norm class (mcolors.Normalize). In that case, we should
generate a new __name__ for the dynamically generated class, to avoid
the slightly confusing situation of having two different classes both
called mcolors.Normalize.

(See the "additional confusion" in the expected outcome section of #20755 (comment).)

PR Summary

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

`make_norm_from_scale` can be used "inline", rather than as a class
decorator, to dynamically create norm classes.  However, in that case,
the second parameter (`base_norm_cls`) would normally be set to the root
base norm class (`mcolors.Normalize`).  In that case, we should
generate a new `__name__` for the dynamically generated class, to avoid
the slightly confusing situation of having two different classes both
called `mcolors.Normalize`.
@anntzer anntzer added this to the v3.5.0 milestone Sep 18, 2021
@story645
story645 merged commit 04a43d6 into matplotlib:master Sep 19, 2021
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Sep 19, 2021
story645 added a commit that referenced this pull request Sep 19, 2021
…112-on-v3.5.x

Backport PR #21112 on branch v3.5.x (Fix make_norm_from_scale `__name__` when used inline.)
@anntzer
anntzer deleted the mnfsn branch September 19, 2021 09:12
tacaswell pushed a commit to tacaswell/matplotlib that referenced this pull request Oct 12, 2021
Fix make_norm_from_scale `__name__` when used inline.
tacaswell pushed a commit that referenced this pull request Oct 20, 2021
Fix make_norm_from_scale `__name__` when used inline.
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.

3 participants