[Numpy-svn] r5508 - in trunk/numpy: ma/tests testing/tests

numpy-svn@scip... numpy-svn@scip...
Tue Jul 22 18:02:34 CDT 2008


Author: alan.mcintyre
Date: 2008-07-22 18:02:29 -0500 (Tue, 22 Jul 2008)
New Revision: 5508

Modified:
   trunk/numpy/ma/tests/test_subclassing.py
   trunk/numpy/testing/tests/test_utils.py
Log:
Standardize NumPy import as "import numpy as np".


Modified: trunk/numpy/ma/tests/test_subclassing.py
===================================================================
--- trunk/numpy/ma/tests/test_subclassing.py	2008-07-22 20:56:27 UTC (rev 5507)
+++ trunk/numpy/ma/tests/test_subclassing.py	2008-07-22 23:02:29 UTC (rev 5508)
@@ -10,25 +10,25 @@
 __revision__ = "$Revision: 3473 $"
 __date__     = '$Date: 2007-10-29 17:18:13 +0200 (Mon, 29 Oct 2007) $'
 
-import numpy as N
+import numpy as np
 import numpy.core.numeric as numeric
 
 from numpy.testing import *
 from numpy.ma.testutils import *
 from numpy.ma.core import *
 
-class SubArray(N.ndarray):
-    """Defines a generic N.ndarray subclass, that stores some metadata
+class SubArray(np.ndarray):
+    """Defines a generic np.ndarray subclass, that stores some metadata
     in the  dictionary `info`."""
     def __new__(cls,arr,info={}):
-        x = N.asanyarray(arr).view(cls)
+        x = np.asanyarray(arr).view(cls)
         x.info = info
         return x
     def __array_finalize__(self, obj):
         self.info = getattr(obj,'info',{})
         return
     def __add__(self, other):
-        result = N.ndarray.__add__(self, other)
+        result = np.ndarray.__add__(self, other)
         result.info.update({'added':result.info.pop('added',0)+1})
         return result
 
@@ -52,13 +52,13 @@
 
 msubarray = MSubArray
 
-class MMatrix(MaskedArray, N.matrix,):
+class MMatrix(MaskedArray, np.matrix,):
     def __new__(cls, data, mask=nomask):
-        mat = N.matrix(data)
+        mat = np.matrix(data)
         _data = MaskedArray.__new__(cls, data=mat, mask=mask)
         return _data
     def __array_finalize__(self,obj):
-        N.matrix.__array_finalize__(self, obj)
+        np.matrix.__array_finalize__(self, obj)
         MaskedArray.__array_finalize__(self,obj)
         return
     def _get_series(self):
@@ -74,7 +74,7 @@
 
     def test_data_subclassing(self):
         "Tests whether the subclass is kept."
-        x = N.arange(5)
+        x = np.arange(5)
         m = [0,0,1,0,0]
         xsub = SubArray(x)
         xmsub = masked_array(xsub, mask=m)
@@ -84,14 +84,14 @@
 
     def test_maskedarray_subclassing(self):
         "Tests subclassing MaskedArray"
-        x = N.arange(5)
+        x = np.arange(5)
         mx = mmatrix(x,mask=[0,1,0,0,0])
-        assert isinstance(mx._data, N.matrix)
+        assert isinstance(mx._data, np.matrix)
         "Tests masked_unary_operation"
         assert isinstance(add(mx,mx), mmatrix)
         assert isinstance(add(mx,x), mmatrix)
         assert_equal(add(mx,x), mx+x)
-        assert isinstance(add(mx,mx)._data, N.matrix)
+        assert isinstance(add(mx,mx)._data, np.matrix)
         assert isinstance(add.outer(mx,mx), mmatrix)
         "Tests masked_binary_operation"
         assert isinstance(hypot(mx,mx), mmatrix)
@@ -126,7 +126,7 @@
 
     def test_subclasspreservation(self):
         "Checks that masked_array(...,subok=True) preserves the class."
-        x = N.arange(5)
+        x = np.arange(5)
         m = [0,0,1,0,0]
         xinfo = [(i,j) for (i,j) in zip(x,m)]
         xsub = MSubArray(x, mask=m, info={'xsub':xinfo})

Modified: trunk/numpy/testing/tests/test_utils.py
===================================================================
--- trunk/numpy/testing/tests/test_utils.py	2008-07-22 20:56:27 UTC (rev 5507)
+++ trunk/numpy/testing/tests/test_utils.py	2008-07-22 23:02:29 UTC (rev 5508)
@@ -1,4 +1,4 @@
-import numpy as N
+import numpy as np
 from numpy.testing import *
 import unittest
 
@@ -19,29 +19,29 @@
 
     def test_array_rank1_eq(self):
         """Test two equal array of rank 1 are found equal."""
-        a = N.array([1, 2])
-        b = N.array([1, 2])
+        a = np.array([1, 2])
+        b = np.array([1, 2])
 
         self._test_equal(a, b)
 
     def test_array_rank1_noteq(self):
         """Test two different array of rank 1 are found not equal."""
-        a = N.array([1, 2])
-        b = N.array([2, 2])
+        a = np.array([1, 2])
+        b = np.array([2, 2])
 
         self._test_not_equal(a, b)
 
     def test_array_rank2_eq(self):
         """Test two equal array of rank 2 are found equal."""
-        a = N.array([[1, 2], [3, 4]])
-        b = N.array([[1, 2], [3, 4]])
+        a = np.array([[1, 2], [3, 4]])
+        b = np.array([[1, 2], [3, 4]])
 
         self._test_equal(a, b)
 
     def test_array_diffshape(self):
         """Test two arrays with different shapes are found not equal."""
-        a = N.array([1, 2])
-        b = N.array([[1, 2], [1, 2]])
+        a = np.array([1, 2])
+        b = np.array([[1, 2], [1, 2]])
 
         self._test_not_equal(a, b)
 
@@ -52,7 +52,7 @@
     def test_generic_rank1(self):
         """Test rank 1 array for all dtypes."""
         def foo(t):
-            a = N.empty(2, t)
+            a = np.empty(2, t)
             a.fill(1)
             b = a.copy()
             c = a.copy()
@@ -71,7 +71,7 @@
     def test_generic_rank3(self):
         """Test rank 3 array for all dtypes."""
         def foo(t):
-            a = N.empty((4, 2, 3), t)
+            a = np.empty((4, 2, 3), t)
             a.fill(1)
             b = a.copy()
             c = a.copy()
@@ -89,35 +89,35 @@
 
     def test_nan_array(self):
         """Test arrays with nan values in them."""
-        a = N.array([1, 2, N.nan])
-        b = N.array([1, 2, N.nan])
+        a = np.array([1, 2, np.nan])
+        b = np.array([1, 2, np.nan])
 
         self._test_equal(a, b)
 
-        c = N.array([1, 2, 3])
+        c = np.array([1, 2, 3])
         self._test_not_equal(c, b)
 
     def test_string_arrays(self):
         """Test two arrays with different shapes are found not equal."""
-        a = N.array(['floupi', 'floupa'])
-        b = N.array(['floupi', 'floupa'])
+        a = np.array(['floupi', 'floupa'])
+        b = np.array(['floupi', 'floupa'])
 
         self._test_equal(a, b)
 
-        c = N.array(['floupipi', 'floupa'])
+        c = np.array(['floupipi', 'floupa'])
 
         self._test_not_equal(c, b)
 
     def test_recarrays(self):
         """Test record arrays."""
-        a = N.empty(2, [('floupi', N.float), ('floupa', N.float)])
+        a = np.empty(2, [('floupi', np.float), ('floupa', np.float)])
         a['floupi'] = [1, 2]
         a['floupa'] = [1, 2]
         b = a.copy()
 
         self._test_equal(a, b)
 
-        c = N.empty(2, [('floupipi', N.float), ('floupa', N.float)])
+        c = np.empty(2, [('floupipi', np.float), ('floupa', np.float)])
         c['floupipi'] = a['floupi'].copy()
         c['floupa'] = a['floupa'].copy()
 



More information about the Numpy-svn mailing list