[Numpy-svn] r3618 - trunk/numpy/core/tests

numpy-svn@scip... numpy-svn@scip...
Fri Mar 30 10:03:33 CDT 2007


Author: stefan
Date: 2007-03-30 10:03:18 -0500 (Fri, 30 Mar 2007)
New Revision: 3618

Modified:
   trunk/numpy/core/tests/test_multiarray.py
Log:
Check clip for byteorder.


Modified: trunk/numpy/core/tests/test_multiarray.py
===================================================================
--- trunk/numpy/core/tests/test_multiarray.py	2007-03-30 13:17:40 UTC (rev 3617)
+++ trunk/numpy/core/tests/test_multiarray.py	2007-03-30 15:03:18 UTC (rev 3618)
@@ -355,17 +355,34 @@
         assert N.all(x >= cmin)
         assert N.all(x <= cmax)
 
-    def _clip_type(self,type_group,amax,cmin,cmax,inplace=False):
+    def _clip_type(self,type_group,array_max,
+                   clip_min,clip_max,inplace=False,
+                   expected_min=None,expected_max=None):
+        if expected_min is None:
+            expected_min = clip_min
+        if expected_max is None:
+            expected_max = clip_max
+
         for T in N.sctypes[type_group]:
-            x = (N.random.random(1000) * amax).astype(T)
-            if inplace:
-                x.clip(cmin,cmax,x)
+            if sys.byteorder == 'little':
+                byte_orders = ['=','>']
             else:
-                x = x.clip(cmin,cmax)
+                byte_orders = ['<','=']
 
-            self._check_range(x,cmin,cmax)
-            return x
+            for byteorder in byte_orders:
+                dtype = N.dtype(T).newbyteorder(byteorder)
+                if dtype.byteorder == '|': byteorder = '|'
 
+                x = (N.random.random(1000) * array_max).astype(dtype)
+                if inplace:
+                    x.clip(clip_min,clip_max,x)
+                else:
+                    x = x.clip(clip_min,clip_max)
+
+                assert_equal(byteorder,x.dtype.byteorder)
+                self._check_range(x,expected_min,expected_max)
+                return x
+
     def check_basic(self):
         for inplace in [False]: # XXX fixme -> ,True]:
             self._clip_type('float',1024,-12.8,100.2)
@@ -375,8 +392,7 @@
             self._clip_type('int',1024,0,0)
 
             # XXX fixme
-            #x = self._check_type('uint',1024,-120,100)
-            #assert N.all(x >= 0)
+            #x = self._check_type('uint',1024,-120,100,expected_min=0)
             x = self._clip_type('uint',1024,0,0)
 
 # Import tests from unicode



More information about the Numpy-svn mailing list