Set norms using scale names. #20752
Set norms using scale names. #20752
Conversation
colors.Normalize)() | ||
norm_cls = type(norm) | ||
norm_cls.__name__ = f"{scale_cls.__name__}Norm" | ||
return norm_cls |
jklymak
Jul 28, 2021
Contributor
I guess this seems overkill to me, and fragile as shown by the pickling issue? Why don't we just use scale._scale_mapping
or make one, i.e. colors._norm_mapping
? Do we really need the extra flexibility given by allowing dynamic creation?
anntzer
Jul 28, 2021
Author
Contributor
I don't really want to create a separate mapping as people can register new scales (e.g. mpl-probscale does it), but they wouldn't show up in the norm mapping if these are separate.
jklymak
Jul 28, 2021
Contributor
Back when I was a whippersnapper, we only had the linear norm and we liked it....
I'm not sure that making this super-flexible is worth the complication. The strings can be for a few common norms. How many specialized scales truly need a norm as well, and how much of a problem is it to ask users to just pass the norm instead to the string? Its not like probscale is going to be a super-useful color norm. If you wanted to add a register_norm
, fine, but making it all dynamic just seems to be asking for trouble.
PR Summary
Proof of concept implementation for #20746.
Still needs a lot of docs, but otherwise mostly works.
Remaining issues:
autoscale()
in LogNorm).PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).