Skip to content

BUG: fix absolute() returning -NaN for +NaN on scalar path - #269

Merged
ndgrigorian merged 3 commits into
IntelPython:mainfrom
vchamarthi:fix/absolute-nan
Sep 12, 2026
Merged

BUG: fix absolute() returning -NaN for +NaN on scalar path#269
ndgrigorian merged 3 commits into
IntelPython:mainfrom
vchamarthi:fix/absolute-nan

Conversation

@vchamarthi

Copy link
Copy Markdown
Contributor

mkl_umath_@TYPE@_absolute's scalar/small-array fallback uses
in1 > 0 ? in1 : -in1, which flips the sign of +NaN since NaN
comparisons are always false. Uses fabs/fabsf instead, which
clears the sign bit unconditionally. Same bug numpy fixed upstream
in dc478c58b9 (gh-31433).

How found

Test failures caught it when upgrading to intel numpy 2.5.3

ndgrigorian
ndgrigorian previously approved these changes Sep 11, 2026
Comment thread mkl_umath/src/mkl_umath_loops.c.src Outdated
ndgrigorian
ndgrigorian previously approved these changes Sep 11, 2026
@ndgrigorian

Copy link
Copy Markdown
Collaborator

@vchamarthi
Also, while we often don't add more tests to mkl_umath, I think in this case it would be good to add a regression test

@ndgrigorian
ndgrigorian merged commit 6dbe9e4 into IntelPython:main Sep 12, 2026
147 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants