iris
iris copied to clipboard
Create an `ApproxConstraint` class
Would solve the problem with floating points.
Could also consider a tolerance argument for Constraint, but there could be clashes with actual variable names.
Team have discussed an alternative API something like ApproxConstraint, which explicitly handles the floating point cases.
- Slower, easier version: convert the
Constraintinto a range functionConstraint - Faster, trickier version: work out what the actual floating point representation of the provided number should be, accounting for the type of the coordinate in question, then use that value in the
Constraintinstead.
Originally posted by @trexfeathers in https://github.com/SciTools/iris/discussions/4744#discussioncomment-2774618
If this does happen, a hypothetical Iris 4 could have this as the default behaviour, and the current strict handling for floating points be a 'StrictConstraint' instead.