summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2021-09-09 09:14:09 -0600
committerGitHub <noreply@github.com>2021-09-09 09:14:09 -0600
commite62aa4968dd0926cf8307a24f06ae0bad4bdabc5 (patch)
treec76098c045fe96830848ec5586aca2ac220cf8b5 /numpy/core
parent8ba424fddf84f49ee9b8c2a60e315d1d4599edc0 (diff)
parent1fe7024c0a3c0d5da985802b3a24a19e312b8673 (diff)
downloadnumpy-e62aa4968dd0926cf8307a24f06ae0bad4bdabc5.tar.gz
Merge pull request #19854 from BvB93/nanfunctions
BUG: Fixed an issue wherein `var` would raise for 0d object arrays
Diffstat (limited to 'numpy/core')
-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,