summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wiebe <mwwiebe@gmail.com>2011-08-18 12:04:49 -0700
committerCharles Harris <charlesr.harris@gmail.com>2011-08-27 07:26:56 -0600
commitc8732958c8e07f2306029dfde2178faf9c01d049 (patch)
tree3c5463cfa4bdd87e4873d30edab424ad9caf1511
parente15712cf5df41806980f040606744040a433b331 (diff)
downloadnumpy-c8732958c8e07f2306029dfde2178faf9c01d049.tar.gz
TST: missingdata: Finish up NA mask tests for np.std and np.var
-rw-r--r--doc/release/2.0.0-notes.rst20
-rw-r--r--numpy/core/tests/test_maskna.py18
2 files changed, 36 insertions, 2 deletions
diff --git a/doc/release/2.0.0-notes.rst b/doc/release/2.0.0-notes.rst
index ca9bc4147..40ad029f0 100644
--- a/doc/release/2.0.0-notes.rst
+++ b/doc/release/2.0.0-notes.rst
@@ -11,7 +11,6 @@ Highlights
New features
============
-
Mask-based NA missing values
----------------------------
@@ -31,7 +30,8 @@ What works with NA:
+ ndarray.clip, ndarray.min, ndarray.max, ndarray.sum, ndarray.prod,
ndarray.conjugate, ndarray.diagonal, ndarray.flatten
+ numpy.concatenate, numpy.column_stack, numpy.hstack,
- numpy.vstack, numpy.dstack, numpy.squeeze
+ numpy.vstack, numpy.dstack, numpy.squeeze, numpy.mean, numpy.std,
+ numpy.var
What doesn't work with NA:
* Fancy indexing, such as with lists and partial boolean masks.
@@ -63,6 +63,22 @@ Differences with R:
This may have a practical advantage in spite of violating the
NA theoretical model, so NumPy could adopt the behavior if necessary
+Reduction UFuncs Generalize axis= Parmaeter
+-------------------------------------------
+
+Any ufunc.reduce function call, as well as other reductions like
+sum, prod, any, all, max and min support the ability to choose
+a subset of the axes to reduce over. Previously, one could say
+axis=None to mean all the axes or axis=# to pick a single axis.
+Now, one can also say axis=(#,#) to pick a list of axes for reduction.
+
+Reduction UFuncs New keepdims= Parameter
+----------------------------------------
+
+There is a new keepdims= parameter, which if set to True, doesn't
+throw away the reduction axes but instead sets them to have size one.
+when this option is set, the reduction result will broadcast correctly
+to the original operand which was reduced.
Custom formatter for printing arrays
diff --git a/numpy/core/tests/test_maskna.py b/numpy/core/tests/test_maskna.py
index ad80f403d..e284f841b 100644
--- a/numpy/core/tests/test_maskna.py
+++ b/numpy/core/tests/test_maskna.py
@@ -1132,6 +1132,24 @@ def test_array_maskna_var_std():
res = np.std(a, axis=1)
assert_array_almost_equal(res, [np.NA, 0.81649658092772603])
+ # With an NA and skipna=True
+ a = np.arange(6, maskna=True).reshape(2,3)
+ a[0,1] = np.NA
+
+ res = np.var(a, skipna=True)
+ assert_almost_equal(res, 2.96)
+ res = np.std(a, skipna=True)
+ assert_almost_equal(res, 1.7204650534085253)
+
+ res = np.var(a, axis=0, skipna=True)
+ assert_array_equal(res, [2.25, 0, 2.25])
+ res = np.std(a, axis=0, skipna=True)
+ assert_array_equal(res, [1.5, 0, 1.5])
+
+ res = np.var(a, axis=1, skipna=True)
+ assert_array_almost_equal(res, [1.0, 0.66666666666666663])
+ res = np.std(a, axis=1, skipna=True)
+ assert_array_almost_equal(res, [1.0, 0.81649658092772603])
if __name__ == "__main__":
run_module_suite()