Skip to content

Use np.isclose for checking bounds of Interval#768

Merged
AdrianSosic merged 5 commits intomainfrom
bug/numerical_target_normalization
Apr 15, 2026
Merged

Use np.isclose for checking bounds of Interval#768
AdrianSosic merged 5 commits intomainfrom
bug/numerical_target_normalization

Conversation

@AVHopp
Copy link
Copy Markdown
Collaborator

@AVHopp AVHopp commented Mar 26, 2026

This PR changes the way that the bounds of Interval objects are compared by using np.isclose.

This fixes #767 as now, the two objects Interval(0, 0.9999999) and Interval(0,1) are considered equal.

@AVHopp AVHopp self-assigned this Mar 26, 2026
Copilot AI review requested due to automatic review settings March 26, 2026 09:52
Comment thread baybe/utils/interval.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() using numpy.isclose on both bounds.
  • Updated NumericalTarget.is_normalized to use Interval.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.

Comment thread baybe/utils/interval.py Outdated
Comment thread tests/validation/test_interval_validation.py Outdated
Comment thread tests/validation/test_interval_validation.py Outdated
Comment thread baybe/targets/numerical.py Outdated
@AVHopp AVHopp force-pushed the bug/numerical_target_normalization branch from 38e6696 to c81db9e Compare March 27, 2026 09:26
@Scienfitz Scienfitz added the bug Something isn't working label Mar 29, 2026
Comment thread CHANGELOG.md Outdated
Comment thread baybe/utils/interval.py Outdated
@AVHopp
Copy link
Copy Markdown
Collaborator Author

AVHopp commented Apr 8, 2026

TODO: Add a note somewhere that the topic of "how do we deal with closeness of numbers" needs to be discussed in more detail

@AVHopp AVHopp force-pushed the bug/numerical_target_normalization branch from 343d7f8 to 469aed5 Compare April 10, 2026 11:33
@AVHopp AVHopp changed the title Add is_close function for `Interval´ class Use math.is_close for equality and contains checks in Interval Apr 10, 2026
@AVHopp AVHopp force-pushed the bug/numerical_target_normalization branch from da295bf to 5802070 Compare April 10, 2026 11:42
Comment thread baybe/utils/interval.py Outdated
@AVHopp AVHopp changed the title Use math.is_close for equality and contains checks in Interval Use np.isclose for checking bounds of Interval Apr 13, 2026
@AVHopp AVHopp force-pushed the bug/numerical_target_normalization branch from 83fdbbb to d79ef17 Compare April 13, 2026 11:24
Comment thread baybe/utils/interval.py Outdated
Comment thread baybe/utils/interval.py Outdated
Comment thread CHANGELOG.md Outdated
Comment thread tests/validation/test_interval_validation.py Outdated
Comment thread tests/validation/test_interval_validation.py Outdated
@AVHopp AVHopp force-pushed the bug/numerical_target_normalization branch from 90d3204 to 7048a3e Compare April 14, 2026 14:41
@AVHopp AVHopp requested a review from AdrianSosic April 14, 2026 14:43
AVHopp and others added 3 commits April 15, 2026 10:09
@AdrianSosic AdrianSosic force-pushed the bug/numerical_target_normalization branch from 7048a3e to 93b7c3a Compare April 15, 2026 08:09
@AdrianSosic AdrianSosic merged commit fc89152 into main Apr 15, 2026
4 of 5 checks passed
@AdrianSosic AdrianSosic deleted the bug/numerical_target_normalization branch April 15, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check for is_normalized for NumericalTarget is too strict

4 participants