Skip to content

Fix limits when numbers are all NaN and we have log scale - #610

Merged
nvaytet merged 3 commits into
mainfrom
fix-all-nan-figs-log-norm
Oct 14, 2026
Merged

nvaytet merged 3 commits into
mainfrom
fix-all-nan-figs-log-norm

Conversation

@nvaytet

@nvaytet nvaytet commented Oct 12, 2026

Copy link
Copy Markdown
Member

This PR fixes the following:

import plopp as pp

a = pp.data.data2d()
a.values[...] = float("nan")

pp.plot(a, norm='log')

It creates a blank figure without raising an error.

Comment thread src/plopp/core/limits.py Outdated
if scale not in ('linear', 'log'):
raise ValueError(f"Unsupported scale: {scale}")
# We decompose value and unit to avoid operation exceptions when unit=None.
unit = lims[0].unit

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are lims[0] and lims[1] guaranteed to have the same unit? The operations below would fail if that is not the case. (This is not new)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As long as fix_empty_range is called on the output of find_limits, this is guaranteed, because find_limits takes in only a single Variable, which has the same unit for all the values it holds.

If fix_empty_range suddenly gets used elsewhere, then you could have that error. I can add a check, I guess it's not too expensive (even though everything adds up when you do many small checks on every plot update).

@nvaytet
nvaytet merged commit 041ab2f into main Oct 14, 2026
5 checks passed
@nvaytet
nvaytet deleted the fix-all-nan-figs-log-norm branch October 14, 2026 13:52
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.

2 participants