[Numpy-svn] r8620 - in branches/1.5.x/numpy/polynomial: . tests

numpy-svn at scipy.org numpy-svn at scipy.org
Tue Aug 10 21:24:22 EDT 2010


Author: charris
Date: 2010-08-10 20:24:21 -0500 (Tue, 10 Aug 2010)
New Revision: 8620

Modified:
   branches/1.5.x/numpy/polynomial/polyutils.py
   branches/1.5.x/numpy/polynomial/tests/test_polyutils.py
Log:
BUG: Backport r8619 to fix ticked #1554.


Modified: branches/1.5.x/numpy/polynomial/polyutils.py
===================================================================
--- branches/1.5.x/numpy/polynomial/polyutils.py	2010-08-11 01:18:21 UTC (rev 8619)
+++ branches/1.5.x/numpy/polynomial/polyutils.py	2010-08-11 01:24:21 UTC (rev 8620)
@@ -289,8 +289,8 @@
     Parameters
     ----------
     old, new : array_like
-        Each domain must (successfully) convert to a 1-d array containing
-        precisely two values.
+        Domains. Each domain must (successfully) convert to a 1-d array
+        containing precisely two values.
 
     Returns
     -------
@@ -330,13 +330,14 @@
     """
     Apply linear map to input points.
 
-    The linear map ``offset + scale*x`` that maps `old` to `new` is applied
-    to the points `x`.
+    The linear map ``offset + scale*x`` that maps the domain `old` to
+    the domain `new` is applied to the points `x`.
 
     Parameters
     ----------
     x : array_like
-        Points to be mapped.
+        Points to be mapped. If `x` is a subtype of ndarray the subtype
+        will be preserved.
     old, new : array_like
         The two domains that determine the map.  Each must (successfully)
         convert to 1-d arrays containing precisely two values.
@@ -388,6 +389,6 @@
     array([-1.0+1.j , -0.6+0.6j, -0.2+0.2j,  0.2-0.2j,  0.6-0.6j,  1.0-1.j ])
 
     """
-    [x] = as_series([x], trim=False)
+    x = np.asanyarray(x)
     off, scl = mapparms(old, new)
     return off + scl*x

Modified: branches/1.5.x/numpy/polynomial/tests/test_polyutils.py
===================================================================
--- branches/1.5.x/numpy/polynomial/tests/test_polyutils.py	2010-08-11 01:18:21 UTC (rev 8619)
+++ branches/1.5.x/numpy/polynomial/tests/test_polyutils.py	2010-08-11 01:24:21 UTC (rev 8620)
@@ -67,9 +67,25 @@
         dom1 = [0 - 1j, 2 + 1j]
         dom2 = [-2, 2]
         tgt = dom2
-        res = pu.mapdomain(dom1, dom1, dom2)
+        x = dom1
+        res = pu.mapdomain(x, dom1, dom2)
         assert_almost_equal(res, tgt)
 
+        # test for multidimensional arrays
+        dom1 = [0,4]
+        dom2 = [1,3]
+        tgt = np.array([dom2, dom2])
+        x = np.array([dom1, dom1])
+        res = pu.mapdomain(x, dom1, dom2)
+        assert_almost_equal(res, tgt)
+
+        # test that subtypes are preserved.
+        dom1 = [0,4]
+        dom2 = [1,3]
+        x = np.matrix([dom1, dom1])
+        res = pu.mapdomain(x, dom1, dom2)
+        assert_(isinstance(res, np.matrix))
+
     def test_mapparms(self) :
         # test for real values
         dom1 = [0,4]




More information about the Numpy-svn mailing list