Skip to content

Commit

Permalink
Refactor conditional logic in _isclose function for better clarity
Browse files Browse the repository at this point in the history
Signed-off-by: Leandro Augusto Lacerda Campos <15185896+leandrolcampos@users.noreply.github.com>
  • Loading branch information
leandrolcampos committed Apr 28, 2024
1 parent ec00140 commit 2c031c9
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions stdlib/src/testing/testing.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn _isclose(
if a.type.is_bool() or a.type.is_integral():
return a == b
else:
var both_nan = (isnan(a) & isnan(b))
var both_nan = isnan(a) & isnan(b)
if equal_nan and both_nan.reduce_and():
return True

Expand All @@ -63,10 +63,7 @@ fn _isclose(
& (_abs(a - b) <= (atol_vec.max(rtol_vec * _abs(a).max(_abs(b)))))
)

if not equal_nan:
return res

return res | both_nan
return res | both_nan if equal_nan else res


# ===----------------------------------------------------------------------=== #
Expand Down

0 comments on commit 2c031c9

Please sign in to comment.