Describe the issue:
With an array q, np.nanquantile(a, q, axis=...) on float32 data normally returns float64. If the first 1-D slice is all-NaN, it returns float32 instead, and every other slice's result is rounded to float32. _nanquantile_ureduce_func uses apply_along_axis, which sizes its output from the first slice's result, and the all-NaN branch returns the input dtype.
Reproduce the code example:
import numpy as np
a = np.array([[1.0, 2.0], [np.nan, np.nan]], dtype=np.float32)
q = np.array([0.3])
print(np.nanquantile(a, q, axis=1).dtype) # float64
print(np.nanquantile(a[::-1], q, axis=1).dtype) # float32
print(np.quantile(a[::-1], q, axis=1).dtype) # float64
Error message:
None. The dtype and values depend on the order of the slices.
Python and NumPy Versions:
NumPy 2.4.6 and 2.5.3, Python 3.12, macOS arm64.
Runtime Environment:
[{'numpy_version': '2.4.6',
'python': '3.12.12 | packaged by Anaconda, Inc. | (main, Oct 21 2025, '
'20:07:49) [Clang 20.1.8 ]',
'uname': uname_result(system='Darwin', node='MCS-MBP.local', release='25.5.0', version='Darwin Kernel Version 25.5.0: Mon Apr 27 20:39:29 PDT 2026; root:xnu-12377.121.6~2/RELEASE_ARM64_T8142', machine='arm64')},
{'simd_extensions': {'baseline': ['NEON', 'NEON_FP16', 'NEON_VFPV4', 'ASIMD'],
'found': ['ASIMDHP', 'ASIMDDP'],
'not_found': ['ASIMDFHM']}},
{'ignore_floating_point_errors_in_matmul': True}]
How does this issue affect you or how did you find it:
Spent significant time chasing down the bug that semi-randomly changed the result type of nanquantile while attempting to identify performance bottlenecks for 4D MRI data.
Describe the issue:
With an array
q,np.nanquantile(a, q, axis=...)on float32 data normally returns float64. If the first 1-D slice is all-NaN, it returns float32 instead, and every other slice's result is rounded to float32._nanquantile_ureduce_funcusesapply_along_axis, which sizes its output from the first slice's result, and the all-NaN branch returns the input dtype.Reproduce the code example:
Error message:
Python and NumPy Versions:
NumPy 2.4.6 and 2.5.3, Python 3.12, macOS arm64.
Runtime Environment:
[{'numpy_version': '2.4.6',
'python': '3.12.12 | packaged by Anaconda, Inc. | (main, Oct 21 2025, '
'20:07:49) [Clang 20.1.8 ]',
'uname': uname_result(system='Darwin', node='MCS-MBP.local', release='25.5.0', version='Darwin Kernel Version 25.5.0: Mon Apr 27 20:39:29 PDT 2026; root:xnu-12377.121.6~2/RELEASE_ARM64_T8142', machine='arm64')},
{'simd_extensions': {'baseline': ['NEON', 'NEON_FP16', 'NEON_VFPV4', 'ASIMD'],
'found': ['ASIMDHP', 'ASIMDDP'],
'not_found': ['ASIMDFHM']}},
{'ignore_floating_point_errors_in_matmul': True}]
How does this issue affect you or how did you find it:
Spent significant time chasing down the bug that semi-randomly changed the result type of nanquantile while attempting to identify performance bottlenecks for 4D MRI data.