diff options
author | pierregm <pierregm@localhost> | 2010-08-11 01:59:39 +0000 |
---|---|---|
committer | pierregm <pierregm@localhost> | 2010-08-11 01:59:39 +0000 |
commit | 6cfb3ff7d24f87257f067359fdf0957fad8f6718 (patch) | |
tree | 14b4e7e393fe830c6c55e00199e2267a4c3f119f /numpy | |
parent | 1994e4ae0f9e98c419793c7d3e6a079aa0c23010 (diff) | |
download | numpy-6cfb3ff7d24f87257f067359fdf0957fad8f6718.tar.gz |
fix (flat)notmasked_/contiguous/edges/
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/ma/extras.py | 26 | ||||
-rw-r--r-- | numpy/ma/tests/test_extras.py | 17 |
2 files changed, 32 insertions, 11 deletions
diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py index 99332b1f3..5ca1e3d1b 100644 --- a/numpy/ma/extras.py +++ b/numpy/ma/extras.py @@ -273,7 +273,7 @@ class _fromnxfunction: if len(args) == 1: x = args[0] if isinstance(x, ndarray): - _d = func(np.asarray(x), **params) + _d = func(x.__array__(), **params) _m = func(getmaskarray(x), **params) return masked_array(_d, mask=_m) elif isinstance(x, tuple) or isinstance(x, list): @@ -292,12 +292,12 @@ class _fromnxfunction: res.append(masked_array(_d, mask=_m)) return res -#atleast_1d = _fromnxfunction('atleast_1d') -#atleast_2d = _fromnxfunction('atleast_2d') -#atleast_3d = _fromnxfunction('atleast_3d') -atleast_1d = np.atleast_1d -atleast_2d = np.atleast_2d -atleast_3d = np.atleast_3d +atleast_1d = _fromnxfunction('atleast_1d') +atleast_2d = _fromnxfunction('atleast_2d') +atleast_3d = _fromnxfunction('atleast_3d') +#atleast_1d = np.atleast_1d +#atleast_2d = np.atleast_2d +#atleast_3d = np.atleast_3d vstack = row_stack = _fromnxfunction('vstack') hstack = _fromnxfunction('hstack') @@ -1742,6 +1742,7 @@ def _ezclump(mask): def clump_unmasked(a): """ Return list of slices corresponding to the unmasked clumps of a 1-D array. + (A "clump" is defined as a contiguous region of the array). Parameters ---------- @@ -1758,6 +1759,11 @@ def clump_unmasked(a): ----- .. versionadded:: 1.4.0 + See Also + -------- + flatnotmasked_edges, flatnotmasked_contiguous, notmasked_edges, + notmasked_contiguous, clump_masked + Examples -------- >>> a = np.ma.masked_array(np.arange(10)) @@ -1780,6 +1786,7 @@ def clump_unmasked(a): def clump_masked(a): """ Returns a list of slices corresponding to the masked clumps of a 1-D array. + (A "clump" is defined as a contiguous region of the array). Parameters ---------- @@ -1796,6 +1803,11 @@ def clump_masked(a): ----- .. versionadded:: 1.4.0 + See Also + -------- + flatnotmasked_edges, flatnotmasked_contiguous, notmasked_edges, + notmasked_contiguous, clump_unmasked + Examples -------- >>> a = np.ma.masked_array(np.arange(10)) diff --git a/numpy/ma/tests/test_extras.py b/numpy/ma/tests/test_extras.py index ce111cfb3..ac33ec0e5 100644 --- a/numpy/ma/tests/test_extras.py +++ b/numpy/ma/tests/test_extras.py @@ -101,7 +101,7 @@ class TestGeneric(TestCase): # a[:] = masked test = flatnotmasked_contiguous(a) - assert_equal(test, []) + assert_equal(test, None) class TestAverage(TestCase): @@ -251,7 +251,7 @@ class TestNotMasked(TestCase): assert_equal(test[1], [(0, 1, 2, 3, 4), (4, 2, 4, 4, 4)]) # test = notmasked_edges(data.data, None) - assert_equal(test, [0, -1]) + assert_equal(test, [0, 24]) test = notmasked_edges(data.data, 0) assert_equal(test[0], [(0, 0, 0, 0, 0), (0, 1, 2, 3, 4)]) assert_equal(test[1], [(4, 4, 4, 4, 4), (0, 1, 2, 3, 4)]) @@ -827,10 +827,19 @@ class TestArraySetOps(TestCase): assert_array_equal(setdiff1d(a, b), np.array(['c'])) + + + class TestShapeBase(TestCase): # - def test_atleast1d(self): - pass + def test_atleast2d(self): + "Test atleast_2d" + a = masked_array([0, 1, 2], mask=[0, 1, 0]) + b = atleast_2d(a) + assert_equal(b.shape, (1, 3)) + assert_equal(b.mask.shape, b.data.shape) + assert_equal(a.shape, (3,)) + assert_equal(a.mask.shape, a.data.shape) ############################################################################### |