summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2021-09-09 11:02:07 +0200
committerBas van Beek <b.f.van.beek@vu.nl>2021-09-09 11:02:07 +0200
commit4f470b35308d93b44215c6adc22636e1176de6fd (patch)
treeee1403c8254f816eb099ae424debdc316cb1ff71
parent548bc6826b597ab79b9c1451b79ec8d23db9d444 (diff)
downloadnumpy-4f470b35308d93b44215c6adc22636e1176de6fd.tar.gz
BUG: Fixed an issue wherein `var` would raise for 0d object arrays
-rw-r--r--numpy/core/_methods.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/numpy/core/_methods.py b/numpy/core/_methods.py
index e475b94df..a239e2c87 100644
--- a/numpy/core/_methods.py
+++ b/numpy/core/_methods.py
@@ -221,8 +221,10 @@ def _var(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False, *,
if isinstance(arrmean, mu.ndarray):
arrmean = um.true_divide(arrmean, div, out=arrmean, casting='unsafe',
subok=False)
- else:
+ elif hasattr(arrmean, "dtype"):
arrmean = arrmean.dtype.type(arrmean / rcount)
+ else:
+ arrmean = arrmean / rcount
# Compute sum of squared deviations from mean
# Note that x may not be inexact and that we need it to be an array,