NCAS-CMS / NCAS-CMS/cf-python

Clarify role of precision when specifying floats to `subspace`

Open
#847 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
150
Forks
23
Avg merge
1d 11h
Merged PRs (30d)
2

Description

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 subspace but perhaps includes other methods (to be investigated);
  • in the tutorial, as (I am thinking) a warning box with an example higlighting an example such as that from the linked Issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the subspace docstring and the tutorial, then investigate other methods that accept float data values for coordinate matching. Document the precision risk and recommend isclose, with a warning example based on the issue; done means the relevant docstrings and tutorial explain how to avoid rounding mismatches.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.