diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-10-04 12:48:24 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-10-04 16:07:38 -0600 |
commit | 2f77e1e6e6b91a9cd11c422342c69e8fd68ee803 (patch) | |
tree | ca37ba09dfec40fa1011f12e688b672e9b371448 /numpy/core/_methods.py | |
parent | 9c7e6e30315ab4541775d9a78630e88423c752c1 (diff) | |
download | numpy-2f77e1e6e6b91a9cd11c422342c69e8fd68ee803.tar.gz |
BUG: Make ndarray.{var, std} work for scalars.
Diffstat (limited to 'numpy/core/_methods.py')
-rw-r--r-- | numpy/core/_methods.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/numpy/core/_methods.py b/numpy/core/_methods.py index 8f0027616..c8a968c97 100644 --- a/numpy/core/_methods.py +++ b/numpy/core/_methods.py @@ -91,8 +91,9 @@ def _var(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False): arrmean = arrmean.dtype.type(arrmean / rcount) # Compute sum of squared deviations from mean - # Note that x may not be inexact - x = arr - arrmean + # Note that x may not be inexact and that we need it to be an array, + # not a scalar. + x = asanyarray(arr - arrmean) if issubclass(arr.dtype.type, nt.complexfloating): x = um.multiply(x, um.conjugate(x), out=x).real else: |