8000 MAINT: Let `_remove_nan_1d` attempt to identify nan-containing object… · howjmay/numpy@d9b27a0 · GitHub
[go: up one dir, main page]

Skip to content

Commit d9b27a0

Browse files
Bas van Beekhowjmay
authored andcommitted
MAINT: Let _remove_nan_1d attempt to identify nan-containing object arrays
Use the same approach as in numpy#9013
1 parent aaf16de commit d9b27a0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

numpy/lib/nanfunctions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,11 @@ def _remove_nan_1d(arr1d, overwrite_input=False):
161161
input
162162
"""
163163
if arr1d.dtype == object:
164-
return arr1d, True
164+
# object arrays do not support `isnan` (gh-9009), so make a guess
165+
c = np.not_equal(arr1d, arr1d, dtype=bool)
166+
else:
167+
c = np.isnan(arr1d)
165168

166-
c = np.isnan(arr1d)
167169
s = np.nonzero(c)[0]
168170
if s.size == arr1d.size:
169171
warnings.warn("All-NaN slice encountered", RuntimeWarning,

0 commit comments

Comments
 (0)
0