FIX: suppress invalid data warnings for handling NaNs in DataRange classes#835
Conversation
|
The tests check that They try to check also that warnings are not emitted, however it is not guaranteed that they would spot a regression, because if a matching warning has already been emitted anywhere else in the test suite, the "once" rule on warnings will already have prevented it to be emitted again. From the docs, it seems like it should be overcomable (emphasis mine):
however, clearing the registry doesn't seem to be easy or supported: https://bugs.python.org/issue21724. CC @mdickinson since this came up in offline discussion. Mark, you're welcome to review if you have time. The core of the PR is based on @rkern's suggestion on Slack. |
corranwebster
left a comment
There was a problem hiding this comment.
Looks good!
Thanks for the contribution.
Fixes #834
BaseDataRangeAPI implementationsDataRange1DDataRange2D¹The default behavior of float comparison with
nans is consistent with themask_dataabstract specification (being "inside the range" implies being finite), so it should be fine to confidently use it without warnings.By the way, all uses of
mask_datain the Chaco codebase outside of the classes themselves are already paired with a& nan_mask. I'm not sure if that's redundant, but it makes me confident that exludingnans from masks is expected everywhere.¹
a curious finding: apparently transposing an array defuses the warning in the first placeDetails
Edit: I was wrong, there is an issue of state. Whichever of the above comparisons gets run first will emit the warning.