From e71a28f3c36b3a2be86d9d6ed472b4d27e63bf8c Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Wed, 23 Jan 2008 22:13:10 +0000 Subject: Add 'compress'. --- numpy/ma/core.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'numpy/ma/core.py') diff --git a/numpy/ma/core.py b/numpy/ma/core.py index bb7e339fc..2ce1a2bd5 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -26,8 +26,8 @@ __all__ = ['MAError', 'MaskType', 'MaskedArray', 'arctanh', 'argmax', 'argmin', 'argsort', 'around', 'array', 'asarray','asanyarray', 'bitwise_and', 'bitwise_or', 'bitwise_xor', - 'ceil', 'choose', 'compressed', 'concatenate', 'conjugate', - 'cos', 'cosh', 'count', + 'ceil', 'choose', 'compress', 'compressed', 'concatenate', + 'conjugate', 'cos', 'cosh', 'count', 'default_fill_value', 'diagonal', 'divide', 'dump', 'dumps', 'empty', 'empty_like', 'equal', 'exp', 'fabs', 'fmod', 'filled', 'floor', 'floor_divide','fix_invalid', @@ -3099,6 +3099,12 @@ def choose (indices, t, out=None, mode='raise'): m = make_mask(mask_or(m, getmask(indices)), copy=0, shrink=True) return masked_array(d, mask=m) +def compress(a, condition): + """Return a where condition is True. + + """ + return a[condition] + def round_(a, decimals=0, out=None): """Return a copy of a, rounded to 'decimals' places. -- cgit v1.2.1