cf-python
cf-python copied to clipboard
Clarify role of precision when specifying floats to `subspace`
From #799 we have seen that specifying a float data value to reference a coordinate value to a method that attempts to match it to some data in the (meta)data, such as subspace, may fail due to the natural unreliability of floating point precision due to rounding, e.g where matching to 0.123 fails but cf.isclose(0.123) will pass.
This isn't covered at all in the documentation, but can mean that users get unexpected results, like with that issue. So it is important to advertise that it is safest to use methods such as isclose when specifying float values if there is reasonable chance for rounding mismatch.
I recommend we clarify this, in (at least) two locations:
- in the docstrings of methods where float data values can be provided, which is at least
subspacebut perhaps includes other methods (to be investigated); - in the tutorial, as (I am thinking) a
warningbox with an example higlighting an example such as that from the linked Issue.