diff options
author | Bas van Beek <b.f.van.beek@vu.nl> | 2021-09-05 23:46:34 +0200 |
---|---|---|
committer | Bas van Beek <b.f.van.beek@vu.nl> | 2021-09-05 23:46:34 +0200 |
commit | ecba7133ffef32b817d53bcb2ceeb3113b37bb07 (patch) | |
tree | 599be9e5de768dadb7142dcf75a4e24e9ae3f72c /numpy/lib/nanfunctions.py | |
parent | a0ea053cd7ee8af1bd05a49b9577eb13fa1e28b7 (diff) | |
download | numpy-ecba7133ffef32b817d53bcb2ceeb3113b37bb07.tar.gz |
MAINT: Let `_remove_nan_1d` attempt to identify nan-containing object arrays
Use the same approach as in numpy/numpy#9013
Diffstat (limited to 'numpy/lib/nanfunctions.py')
-rw-r--r-- | numpy/lib/nanfunctions.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/numpy/lib/nanfunctions.py b/numpy/lib/nanfunctions.py index 46c71e1f5..766bf3c82 100644 --- a/numpy/lib/nanfunctions.py +++ b/numpy/lib/nanfunctions.py @@ -161,9 +161,11 @@ def _remove_nan_1d(arr1d, overwrite_input=False): input """ if arr1d.dtype == object: - return arr1d, True + # object arrays do not support `isnan` (gh-9009), so make a guess + c = np.not_equal(arr1d, arr1d, dtype=bool) + else: + c = np.isnan(arr1d) - c = np.isnan(arr1d) s = np.nonzero(c)[0] if s.size == arr1d.size: warnings.warn("All-NaN slice encountered", RuntimeWarning, |