diff options
author | Bas van Beek <b.f.van.beek@vu.nl> | 2021-05-22 15:48:23 +0200 |
---|---|---|
committer | Bas van Beek <b.f.van.beek@vu.nl> | 2021-05-22 16:04:47 +0200 |
commit | f91f4bcd050299c930092390b54ce9ba51fd70e0 (patch) | |
tree | e28ac4d33e707f7e6b7f0691db0cbc39a64b8ab4 /numpy/lib/nanfunctions.py | |
parent | 7de0fa959e476900725d8a654775e0a38745de08 (diff) | |
download | numpy-f91f4bcd050299c930092390b54ce9ba51fd70e0.tar.gz |
BUG: Fixed an issue wherein `nanmedian` could return an array with the wrong dtype
Diffstat (limited to 'numpy/lib/nanfunctions.py')
-rw-r--r-- | numpy/lib/nanfunctions.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/numpy/lib/nanfunctions.py b/numpy/lib/nanfunctions.py index a02ad779f..02ad01a98 100644 --- a/numpy/lib/nanfunctions.py +++ b/numpy/lib/nanfunctions.py @@ -965,7 +965,9 @@ def _nanmedian1d(arr1d, overwrite_input=False): arr1d, overwrite_input = _remove_nan_1d(arr1d, overwrite_input=overwrite_input) if arr1d.size == 0: - return np.nan + # Ensure that a nan-esque scalar of the appropiate type (and unit) + # is returned for `timedelta64` and `complexfloating` + return np.array(np.nan).astype(arr1d.dtype, copy=False)[()] return np.median(arr1d, overwrite_input=overwrite_input) |