Use np.isclose for checking bounds of Interval#768
Merged
AdrianSosic merged 5 commits intomainfrom Apr 15, 2026
Merged
Conversation
AVHopp
commented
Mar 26, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a fuzzy interval-boundary comparison utility to address overly strict normalization checks (Issue #767), replacing exact Interval(0, 1) comparisons with a tolerance-based approach.
Changes:
- Added
Interval.is_close()usingnumpy.iscloseon both bounds. - Updated
NumericalTarget.is_normalizedto useInterval.is_close(Interval(0, 1))instead of strict equality. - Added validation tests for closeness behavior and documented the change in the changelog.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
baybe/utils/interval.py |
Introduces Interval.is_close() for fuzzy boundary comparison. |
baybe/targets/numerical.py |
Switches normalization detection to use the new fuzzy comparison. |
tests/validation/test_interval_validation.py |
Adds tests for Interval.is_close() behavior. |
CHANGELOG.md |
Documents the new API and the normalization-check fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
38e6696 to
c81db9e
Compare
Scienfitz
requested changes
Apr 8, 2026
Collaborator
Author
|
TODO: Add a note somewhere that the topic of "how do we deal with closeness of numbers" needs to be discussed in more detail |
343d7f8 to
469aed5
Compare
is_close function for `Interval´ classmath.is_close for equality and contains checks in Interval
da295bf to
5802070
Compare
Scienfitz
approved these changes
Apr 10, 2026
AVHopp
commented
Apr 10, 2026
math.is_close for equality and contains checks in Intervalnp.isclose for checking bounds of Interval
83fdbbb to
d79ef17
Compare
AdrianSosic
requested changes
Apr 14, 2026
90d3204 to
7048a3e
Compare
Co-authored-by: AdrianSosic <adrian.sosic@merckgroup.com>
7048a3e to
93b7c3a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR changes the way that the bounds of
Intervalobjects are compared by usingnp.isclose.This fixes #767 as now, the two objects
Interval(0, 0.9999999)andInterval(0,1)are considered equal.