summaryrefslogtreecommitdiff
path: root/numpy/lib/nanfunctions.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2014-05-05 16:44:39 -0600
committerCharles Harris <charlesr.harris@gmail.com>2014-05-06 16:24:10 -0600
commitff99924f3a82ee09cb76cc6cc94fc196a112fb30 (patch)
treede9cae03a83b37048c90e5429d246a6bd1d43da1 /numpy/lib/nanfunctions.py
parent6f5329fdf45dc97314fa593d0a5a4c1d24e753c5 (diff)
downloadnumpy-ff99924f3a82ee09cb76cc6cc94fc196a112fb30.tar.gz
MAINT: Change default inplace, ufunc(...,out=x) casting to same_kind.
There has been a warning of this change since numpy 1.7. numpy 1.10 is a good time to do it. The nanvar function needed a fix after the change, and the tests and documentation are updated.
Diffstat (limited to 'numpy/lib/nanfunctions.py')
-rw-r--r--numpy/lib/nanfunctions.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/numpy/lib/nanfunctions.py b/numpy/lib/nanfunctions.py
index 818e130a8..e6b375884 100644
--- a/numpy/lib/nanfunctions.py
+++ b/numpy/lib/nanfunctions.py
@@ -35,6 +35,10 @@ def _replace_nan(a, val):
marking the locations where NaNs were present. If `a` is not of
inexact type, do nothing and return `a` together with a mask of None.
+ Note that scalars will end up as array scalars, which is important
+ for using the result as the value of the out argument in some
+ operations.
+
Parameters
----------
a : array-like
@@ -850,7 +854,7 @@ def nanvar(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False):
avg = _divide_by_count(avg, cnt)
# Compute squared deviation from mean.
- arr -= avg
+ np.subtract(arr, avg, out=arr, casting='unsafe')
arr = _copyto(arr, 0, mask)
if issubclass(arr.dtype.type, np.complexfloating):
sqr = np.multiply(arr, arr.conj(), out=arr).real