Skip to content
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

Noisy UserWarning is thrown (np.longdouble) when importing nibabel with numpy>=1.25 on WSL1 #1309

Closed
joshuacwnewton opened this issue Mar 22, 2024 · 2 comments · Fixed by #1310
Assignees

Comments

@joshuacwnewton
Copy link
Contributor

joshuacwnewton commented Mar 22, 2024

Note

This seems to be a relatively narrow warning, since numpy<=1.24 doesn't throw this warning, nor does WSL2, nor does the native Windows package.

The warning thrown by numpy is:

numpy/core/getlimits.py:542:  
"""
UserWarning: Signature b'\x00\xd0\xcc\xcc\xcc\xcc\xcc\xcc\xfb\xbf\x00\x00\x00\x00\x00\x00' for 
<class 'numpy.longdouble'> does not match any known type: falling back to type probe function.
This warnings indicates broken support for the dtype!
  machar = _get_machar(dtype)
"""

When importing nibabel, the following stack trace occurs:

  • import nibabel -> .analyze -> .arrayproxy -> .volumeutils -> .casting -> ok_floats()
  • nibabel.casting.ok_floats() -> best_float() -> type_info(np.longdouble) -> np.finfo(np.longdouble) -> warning

Reading the source code of best_float(), I see that nibabel actively tries to avoid np.longdouble on Windows:

nibabel/nibabel/casting.py

Lines 667 to 670 in 0e925ab

This is nearly always np.longdouble, except on Windows, where np.longdouble
is Intel80 storage, but with float64 precision for calculations. In that
case we return float64 on the basis it's the fastest and smallest at the
highest precision.

Given nibabel's intentions here, it seems as though the warning is largely noise? So, I thought I would mention it here in case nibabel wishes to filter this warning.

Related issues:

@effigies
Copy link
Member

Seems worth filtering. Any interest in proposing a patch?

@joshuacwnewton
Copy link
Contributor Author

Sure thing! Feel free to assign me. :)

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 a pull request may close this issue.

2 participants