[Numpy-svn] r8474 - in trunk/numpy/random: mtrand tests
numpy-svn at scipy.org
numpy-svn at scipy.org
Fri Jul 9 04:11:40 EDT 2010
Author: ptvirtan
Date: 2010-07-09 03:11:39 -0500 (Fri, 09 Jul 2010)
New Revision: 8474
Modified:
trunk/numpy/random/mtrand/mtrand.pyx
trunk/numpy/random/tests/test_random.py
Log:
BUG: random: accept Python long as input to np.random.permutation (#1535)
Modified: trunk/numpy/random/mtrand/mtrand.pyx
===================================================================
--- trunk/numpy/random/mtrand/mtrand.pyx 2010-07-07 04:32:00 UTC (rev 8473)
+++ trunk/numpy/random/mtrand/mtrand.pyx 2010-07-09 08:11:39 UTC (rev 8474)
@@ -4226,7 +4226,7 @@
array([15, 1, 9, 4, 12])
"""
- if isinstance(x, (int, np.integer)):
+ if isinstance(x, (int, long, np.integer)):
arr = np.arange(x)
else:
arr = np.array(x)
Modified: trunk/numpy/random/tests/test_random.py
===================================================================
--- trunk/numpy/random/tests/test_random.py 2010-07-07 04:32:00 UTC (rev 8473)
+++ trunk/numpy/random/tests/test_random.py 2010-07-09 08:11:39 UTC (rev 8474)
@@ -34,6 +34,12 @@
msg = "Frequency was %f, should be < 0.23" % freq
assert_(freq < 0.23, msg)
+ def test_permutation_longs(self):
+ np.random.seed(1234)
+ a = np.random.permutation(12)
+ np.random.seed(1234)
+ b = np.random.permutation(12L)
+ assert_array_equal(a, b)
class TestMultinomial(TestCase):
def test_basic(self):
More information about the Numpy-svn
mailing list