Skip to content

Commit a0ea053

Browse files
committed
MAINT: Copy the _methods._std code-path for handling nanstd object-arrays
https://github.com/numpy/numpy/blob/410a89ef04a2d3c50dd2dba2ad403c872c3745ac/numpy/core/_methods.py#L265-L270
1 parent 9ef7783 commit a0ea053

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

numpy/lib/nanfunctions.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,11 +1683,8 @@ def nanstd(a, axis=None, dtype=None, out=None, ddof=0, keepdims=np._NoValue):
16831683
keepdims=keepdims)
16841684
if isinstance(var, np.ndarray):
16851685
std = np.sqrt(var, out=var)
1686+
elif hasattr(var, 'dtype'):
1687+
std = var.dtype.type(np.sqrt(var))
16861688
else:
1687-
# Precaution against reduced object arrays
1688-
try:
1689-
std = var.dtype.type(np.sqrt(var))
1690-
except AttributeError:
1691-
cls = type(var)
1692-
std = cls(np.sqrt(var))
1689+
std = np.sqrt(var)
16931690
return std

0 commit comments

Comments
 (0)