[Numpy-svn] r8621 - in trunk/numpy/ma: . tests

numpy-svn@scip... numpy-svn@scip...
Tue Aug 10 20:59:39 CDT 2010


Author: pierregm
Date: 2010-08-10 20:59:39 -0500 (Tue, 10 Aug 2010)
New Revision: 8621

Modified:
   trunk/numpy/ma/extras.py
   trunk/numpy/ma/tests/test_extras.py
Log:
fix (flat)notmasked_/contiguous/edges/

Modified: trunk/numpy/ma/extras.py
===================================================================
--- trunk/numpy/ma/extras.py	2010-08-11 01:24:21 UTC (rev 8620)
+++ trunk/numpy/ma/extras.py	2010-08-11 01:59:39 UTC (rev 8621)
@@ -273,7 +273,7 @@
         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 @@
                 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 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 @@
     -----
     .. 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_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 @@
     -----
     .. 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))

Modified: trunk/numpy/ma/tests/test_extras.py
===================================================================
--- trunk/numpy/ma/tests/test_extras.py	2010-08-11 01:24:21 UTC (rev 8620)
+++ trunk/numpy/ma/tests/test_extras.py	2010-08-11 01:59:39 UTC (rev 8621)
@@ -101,7 +101,7 @@
         #
         a[:] = masked
         test = flatnotmasked_contiguous(a)
-        assert_equal(test, [])
+        assert_equal(test, None)
 
 
 class TestAverage(TestCase):
@@ -251,7 +251,7 @@
         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 @@
         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)
 
 
 ###############################################################################



More information about the Numpy-svn mailing list