From ecba7133ffef32b817d53bcb2ceeb3113b37bb07 Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Sun, 5 Sep 2021 23:46:34 +0200 Subject: MAINT: Let `_remove_nan_1d` attempt to identify nan-containing object arrays Use the same approach as in numpy/numpy#9013 --- numpy/lib/nanfunctions.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'numpy/lib/nanfunctions.py') 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, -- cgit v1.2.1