[Numpy-svn] r3893 - in trunk/numpy: core/tests oldnumeric

numpy-svn@scip... numpy-svn@scip...
Mon Jul 23 08:13:19 CDT 2007


Author: stefan
Date: 2007-07-23 08:12:55 -0500 (Mon, 23 Jul 2007)
New Revision: 3893

Modified:
   trunk/numpy/core/tests/test_regression.py
   trunk/numpy/oldnumeric/random_array.py
Log:
Fix randint. Closes ticket #552.


Modified: trunk/numpy/core/tests/test_regression.py
===================================================================
--- trunk/numpy/core/tests/test_regression.py	2007-07-20 11:28:43 UTC (rev 3892)
+++ trunk/numpy/core/tests/test_regression.py	2007-07-23 13:12:55 UTC (rev 3893)
@@ -697,6 +697,11 @@
         x = N.array(['a']*32)
         assert_array_equal(x.argsort(kind='m'), N.arange(32))
 
+    def check_numeric_random(self, level=rlevel):
+        """Ticket #552"""
+        from numpy.oldnumeric.random_array import randint
+        randint(0,50,[2,3])
 
+
 if __name__ == "__main__":
     NumpyTest().run()

Modified: trunk/numpy/oldnumeric/random_array.py
===================================================================
--- trunk/numpy/oldnumeric/random_array.py	2007-07-20 11:28:43 UTC (rev 3892)
+++ trunk/numpy/oldnumeric/random_array.py	2007-07-23 13:12:55 UTC (rev 3893)
@@ -12,8 +12,6 @@
 import numpy.random.mtrand as mt
 import numpy as Numeric
 
-from types import IntType
-
 def seed(x=0, y=0):
     if (x == 0 or y == 0):
         mt.seed()
@@ -42,16 +40,16 @@
 def randint(minimum, maximum=None, shape=[]):
     """randint(min, max, shape=[]) = random integers >=min, < max
     If max not given, random integers >= 0, <min"""
-    if not isinstance(minimum, IntType):
+    if not isinstance(minimum, int):
         raise ArgumentError, "randint requires first argument integer"
     if maximum is None:
         maximum = minimum
         minimum = 0
-    if not isinstance(maximum, IntType):
+    if not isinstance(maximum, int):
         raise ArgumentError, "randint requires second argument integer"
     a = ((maximum-minimum)* random(shape))
-    if isinstance(a, Numeric.ArrayType):
-        return minimum + a.astype(Numeric.Int)
+    if isinstance(a, Numeric.ndarray):
+        return minimum + a.astype(Numeric.int)
     else:
         return minimum + int(a)
 



More information about the Numpy-svn mailing list