Fix ValueError when using string norm with vmin/vmax#692
Closed
Ai-chan-0411 wants to merge 1 commit intoUltraplot:mainfrom
Closed
Fix ValueError when using string norm with vmin/vmax#692Ai-chan-0411 wants to merge 1 commit intoUltraplot:mainfrom
Ai-chan-0411 wants to merge 1 commit intoUltraplot:mainfrom
Conversation
The check that rejected vmin/vmax when norm was set was too strict — it blocked the case where norm is a string like "log" that still needs vmin/vmax forwarded to the normalizer constructor. The guard now only fires when norm is an already-instantiated Normalize object, which carries its own vmin/vmax and would conflict with explicit values. Fixes Ultraplot#689
Collaborator
Author
|
Thanks for reviewing and closing this! I appreciate you pointing to PR #662 as the preferred approach for handling this ValueError issue. I'll keep that pattern in mind for future contributions. |
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When calling plotting methods like
pcolormeshwith a string normalizer (e.g.norm="log") and explicitvmin/vmaxlimits, the current code raisesValueError: If 'norm' is given, 'vmin' and 'vmax' must not be set.even though this combination is perfectly valid — the string norm needs to be constructed with those limits.I ran into this while trying to plot log-scaled data with a custom lower bound (
vmin=1e-2). The guard in_parse_cmapwas checkingnorm is not Nonewhen it should only reject the case wherenormis an already-instantiatedNormalizeobject (which carries its own vmin/vmax internally). Whennormis a string or tuple, it gets passed toconstructor.Norm()later, which accepts vmin/vmax as constructor arguments.The fix narrows the check to
isinstance(norm, mcolors.Normalize)so that string-based norms can coexist with explicit limits. I also added a regression test that confirmspcolormesh(data, norm="log", vmin=1e-2)works without error and the resulting normalizer has the expected vmin.Fixes #689