Make blank plot instead of raising on all nan#584
Conversation
| values = fix_empty_range(find_limits(x, scale=scale, pad=pad)) | ||
| values = find_limits(x, scale=scale, pad=pad) | ||
| if np.isnan(values[0].value) or np.isnan(values[1].value): | ||
| return dict.fromkeys(keys, None) |
There was a problem hiding this comment.
If this is really meant to be treated equivalently to the case that raises ValueError then it could make sense to raise ValueError here too instead of returning the dict, so that we avoid duplicating that logic.
There was a problem hiding this comment.
I think here we want to make a bbox with None, so that it gets ignored.
Say you plot 2 lines, and one of them has all NaN. I would expect to just see one line instead of having an error raised. You might then wonder why you have just one line, and in that case raising an error may be safer. But in the case of interactive plots, where one slice somewhere may have all nans and the others are fine, I think it makes sense to not show the data instead of raising.
There was a problem hiding this comment.
I didn't mean to raise an error that is visible to the user. I meant that the ValueError will be catched by the surrounding try/catch, and then we return the same dict.fromkeys anyway but with less duplication.
There was a problem hiding this comment.
So what you meant was:
values = find_limits(x, scale=scale, pad=pad)
if np.isnan(values[0].value) or np.isnan(values[1].value):
raise ValueError("NaN limits")?
Sometimes you have a slice of data that contains all NaNs, but you still want to inspect the rest of the data with e.g. the
slicer.Example:
This would raise with a message saying it cannot compute limits because data is all NaN.
Now we instead return a NaN range, which get converted to a null range [0, 0].
The plot is just blank instead. Moving the slider can still be used to view other healthy slices.