-
Notifications
You must be signed in to change notification settings - Fork 435
EAMxx: handle potential nan in within-interval checks #7385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EAMxx: handle potential nan in within-interval checks #7385
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR inverts the comparison logic in the min/max value checks, replacing direct <
/>
operations with negated >=
/<=
expressions across multiple dimensional lambdas.
- Swapped
v(...) < result.min_val
tonot v(...)>=result.min_val
- Swapped
v(...) > result.max_val
tonot v(...)<=result.max_val
- Applied change consistently for 1D through 6D views
Comments suppressed due to low confidence (2)
components/eamxx/src/share/property_checks/field_within_interval_check.cpp:99
- The expression
not v(i)>=result.min_val
is parsed as(not v(i)) >= result.min_val
, which is almost certainly not the intended logic. Use!(v(i) >= result.min_val)
or revert tov(i) < result.min_val
for correctness.
if (not v(i)>=result.min_val) {
components/eamxx/src/share/property_checks/field_within_interval_check.cpp:103
- Similarly,
not v(i)<=result.max_val
is parsed as(not v(i)) <= result.max_val
, which does not implement the intendedv(i) > result.max_val
. Consider!(v(i) <= result.max_val)
orv(i) > result.max_val
.
if (not v(i)<=result.max_val) {
components/eamxx/src/share/property_checks/field_within_interval_check.cpp
Outdated
Show resolved
Hide resolved
112821b
to
9b222b9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR inverts the comparison logic used in the min/max value checks across all dimensional variants of the FieldWithinIntervalCheck
parallel reductions.
- Replaces direct
<
/>
checks with negated>=
/<=
expressions for min/max comparisons. - Applies this change consistently for 1D through 7D fields.
- No change in overall algorithmic behavior (BFB).
Comments suppressed due to low confidence (2)
components/eamxx/src/share/property_checks/field_within_interval_check.cpp:99
- [nitpick] Using an inverted
not (v(i) >= result.min_val)
reduces readability compared to a directv(i) < result.min_val
. Consider reverting to the simpler form for clarity.
if (not (v(i) >= result.min_val)) {
components/eamxx/src/share/property_checks/field_within_interval_check.cpp:103
- [nitpick] Using an inverted
not (v(i) <= result.max_val)
reduces readability compared to a directv(i) > result.max_val
. Consider using the direct comparison.
if (not (v(i) <= result.max_val)) {
@mahf708 : Does the |
yeah, should work; note we use Here, the goal is to ensure the FieldWithinIntervalCheck is sound (nan cannot really be in any bounded internval [a, b] by definition, or at least by any reasonable assumption). The problem was that we were silently ignoring the possibility of nan in [a, b] when where were checking the values... thus nan ending up circumventing the check altogether :/ |
inverts comparison logic in property checks to use IEEE 754 (NaN < value returns false; NaN > value returns false) to carefully account for the existence of NaN values in comparisons instead of silently ignoring them.
Fixes #7384
[BFB]