Skip to content

BUG,TST: Fix condition for whether long double is “IBM double double”.#31375

Open
manueljacob wants to merge 1 commit into
numpy:mainfrom
manueljacob:tests-double-double
Open

BUG,TST: Fix condition for whether long double is “IBM double double”.#31375
manueljacob wants to merge 1 commit into
numpy:mainfrom
manueljacob:tests-double-double

Conversation

@manueljacob
Copy link
Copy Markdown

Some distributions changed the default for long double on 64-bit PowerPC (at least little-endian) from the “IBM double double” format to the IEEE 754 binary128 format. The implementation already handles that by detecting the format at build time (longdouble_format property). Before this change, the tests checked only the CPU architecture name, possibly falsely assuming that long double has the “IBM double double” format when it actually has the IEEE 754 binary128 format. After this change, the tests assume the “IBM double double” format only if the maximum value, determined by calling numpy.finfo(), is the maximum value characteristic for the “IBM double double” format. On CPU architectures other than PowerPC, the “IBM double double” format is never assumed. I found no evidence that any other CPU architecture ever used that format.

On a system where long double has the “IBM double double” format, the test results don’t change:

47406 passed, 1047 skipped, 2845 deselected, 32 xfailed, 4 xpassed

On a system where long double has the IEEE 754 binary128 format, the test results change from:

1 failed, 47404 passed, 1049 skipped, 2845 deselected, 32 xfailed, 4 xpassed

to:

47408 passed, 1048 skipped, 2845 deselected, 32 xfailed, 2 xpassed

Fixes #21094.

First time committer introduction

I rarely use NumPy directly. I encountered one of the previous test failures when building the NumPy package in the Nix package collection (which runs the tests).

AI Disclosure

No AI tools used

@manueljacob manueljacob force-pushed the tests-double-double branch from 7a76cdc to ed5f56c Compare May 3, 2026 12:36
@charris charris added 00 - Bug 03 - Maintenance triage review Issue/PR to be discussed at the next triage meeting labels May 11, 2026
Some distributions changed the default for long double on 64-bit PowerPC
(at least little-endian) from the “IBM double double” format to the IEEE
754 binary128 format. The implementation already handles that by
detecting the format at build time (longdouble_format property). Before
this change, the tests checked only the CPU architecture name, possibly
falsely assuming that long double has the “IBM double double” format
when it actually has the IEEE 754 binary128 format. After this change,
the tests assume the “IBM double double” format only if the maximum
value, determined by calling numpy.finfo(), is the maximum value
characteristic for the “IBM double double” format. On CPU architectures
other than PowerPC, the “IBM double double” format is never assumed. I
found no evidence that any other CPU architecture ever used that format.

On a system where long double has the “IBM double double” format, the
test results don’t change:

47406 passed, 1047 skipped, 2845 deselected, 32 xfailed, 4 xpassed

On a system where long double has the IEEE 754 binary128 format, the
test results change from:

1 failed, 47404 passed, 1049 skipped, 2845 deselected, 32 xfailed, 4 xpassed

to:

47408 passed, 1048 skipped, 2845 deselected, 32 xfailed, 2 xpassed

Fixes numpy#21094.
@manueljacob manueljacob force-pushed the tests-double-double branch from ed5f56c to eba6eab Compare May 11, 2026 19:56
Copy link
Copy Markdown
Member

@seberg seberg left a comment

Choose a reason for hiding this comment

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

Makes sense to me, I would prefer to tweak the definition slightly. If I have a good idea, I might also just apply that.


LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE = (platform.machine().startswith("ppc")
and str(np.finfo(np.longdouble).max)
== "1.79769313486231580793728971405301e+308")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would it make sense to just drop the PPC entirely? I would also slightly prefer to nmant (or even also nexp), not quite as distinct in theory, but then we don't have to trust string formatters (I don't really trust them, although I guess that one test would maybe fail if they failed)...

(A bit pattern would work as well, but one special value or two seems distinct enough, I would agree.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

00 - Bug 03 - Maintenance triage review Issue/PR to be discussed at the next triage meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: Support IEEE long double on ppc64 in tests

3 participants