summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2021-09-11 13:54:56 +0200
committerBas van Beek <b.f.van.beek@vu.nl>2021-09-11 13:54:56 +0200
commit95e5d5abbfa6d1f7e5d0ca5d9e6edc60650cb6a6 (patch)
tree2e25e85ee1212ce23f24144134eaefe1d7c9aef4
parentb892ed2c7fa27b2e0d73c12d12ace4b4d4e12897 (diff)
downloadnumpy-95e5d5abbfa6d1f7e5d0ca5d9e6edc60650cb6a6.tar.gz
BUG: Fixed an issue wherein `nanpercentile` and `nanquantile` would ignore the dtype for all-nan arrays
-rw-r--r--numpy/lib/nanfunctions.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/numpy/lib/nanfunctions.py b/numpy/lib/nanfunctions.py
index 766bf3c82..658ec5255 100644
--- a/numpy/lib/nanfunctions.py
+++ b/numpy/lib/nanfunctions.py
@@ -1421,7 +1421,8 @@ def _nanquantile_1d(arr1d, q, overwrite_input=False, interpolation='linear'):
arr1d, overwrite_input = _remove_nan_1d(arr1d,
overwrite_input=overwrite_input)
if arr1d.size == 0:
- return np.full(q.shape, np.nan)[()] # convert to scalar
+ # convert to scalar
+ return np.full(q.shape, np.nan, dtype=arr1d.dtype)[()]
return function_base._quantile_unchecked(
arr1d, q, overwrite_input=overwrite_input, interpolation=interpolation)