Added tolerances to Coord.is_contiguous()#459
Conversation
There was a problem hiding this comment.
Do we need to reproduce numpy's defaults here?
There was a problem hiding this comment.
I cannot come up with a neat way not to. Feel free to suggest one, but I'm happy to have clearly stated, documented defaults and simple code.
There was a problem hiding this comment.
@bblay - do you have any outstanding objections to this being merged?
There was a problem hiding this comment.
Apologies @esc24 but I could not finish the review.
My comment about defaults, above, was just wondering if we could just pass through None instead,
and refer to the np func for defaults. This would allow np to change them and we'd stay up-to-date.
|
👍 - I'd be happy to merge this. |
Added tolerances to Coord.is_contiguous()
There was a problem hiding this comment.
Might be worth adding a comment in here as this is an important test, perhaps something like,
bounds[0,1] differs from bounds[1,0] around the 16th decimal place.
Alternatively, it might make the test clearer if you were to simply hard-code the values?
|
👍 There are a few trivial comments you might choose to act on, but I'd be happy for this to be merged now. |
I'm guessing you missed the fact that it had already been merged 😄. Its up to you if you'd like Ed to follow up on those comments in a follow-up PR.
No, you can't do this. None is a legitimate argument and almost all functions (unless None means "use a default value" and is typically only done for mutable default values). |
|
Doh! 😊 They removed the red box saying merged. |
The
iris.coords.Coord.is_contiguous()method tests for equality between adjacent upper and lower bounds to determine whether bounds are contiguous. This runs into issues with floating point numbers. For example:returns False.
This PR modifies
is_contiguous()to usenp.allclose()adding the tolerance keyword args tois_contiguous().