Skip to content

Fix/norm inputs - #693

Merged
cvanelteren merged 11 commits into
mainfrom
fix/norm-inputs
Apr 20, 2026
Merged

Fix/norm inputs#693
cvanelteren merged 11 commits into
mainfrom
fix/norm-inputs

Conversation

@cvanelteren

@cvanelterencvanelteren commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

Closes#689

When vmin, vmax is given, norms should not be allowed as inputs (as they are part of the norm object). When strings are given, however, we must allow the logic to run.

@codecov

codecovBot commented Apr 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing linesPatch %Lines
ultraplot/tests/test_colorbar.py94.28%1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@cvanelteren

Copy link
Copy Markdown
CollaboratorAuthor

@gepcel@munechika-koyo can this be merged?


@pytest.mark.parametrize(
"norm",
["linear", ["linear"], ("linear",)],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
["linear", ["linear"], ("linear",)],
["linear", "log", ["linear"], ("linear",)],

What about trying a different norm?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

We could; I am currently just testing against the explicit inputs which are str, list or tuple

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I understand that we conducted the type testing there.
It is probably confirmed somewhere that parsing a string and converting it into the corresponding normalizer is possible, so it might not be necessary here.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

I will check

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

I added this test

@pytest.mark.parametrize("norm", [uplt.DiscreteNorm, uplt.colors.mcolors.Normalize])deftest_normalize_types(norm):
data=np.random.rand(10, 10)
target=normprint(norm)
ifnormisuplt.DiscreteNorm:
norm=uplt.DiscreteNorm(levels=[0, 1])
discrete=Trueelifnormisuplt.colors.mcolors.Normalize:
norm=uplt.colors.mcolors.Normalize(vmin=0, vmax=1)
discrete=Falseelse:
raiseValueError("Norm not understood.")
fig, ax=uplt.subplots()
cm=ax.pcolormesh(data, norm=norm, discrete=discrete)
assertisinstance(cm.norm, target)

@cvanelteren
cvanelteren merged commit 8bf6ccb into mainApr 20, 2026
19 checks passed
@cvanelteren
cvanelteren deleted the fix/norm-inputs branch April 20, 2026 07:17
Sign up for freeto 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.

Normalizer with corresponding parameters doesn't work?

3 participants

@cvanelteren@gepcel@munechika-koyo