diff options
author | Pauli Virtanen <pav@iki.fi> | 2010-07-09 08:11:39 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2010-07-09 08:11:39 +0000 |
commit | 237ed35fd848dc5a312e15206b4d729cd2e91f90 (patch) | |
tree | 7759d771b07dbc0c1563dc7c0e2a8cbca5c88060 | |
parent | 8bb282307481e208f972a72c5745c63e2404cd66 (diff) | |
download | numpy-237ed35fd848dc5a312e15206b4d729cd2e91f90.tar.gz |
BUG: random: accept Python long as input to np.random.permutation (#1535)
-rw-r--r-- | numpy/random/mtrand/mtrand.pyx | 2 | ||||
-rw-r--r-- | numpy/random/tests/test_random.py | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/numpy/random/mtrand/mtrand.pyx b/numpy/random/mtrand/mtrand.pyx index 0340bef62..13aa111b2 100644 --- a/numpy/random/mtrand/mtrand.pyx +++ b/numpy/random/mtrand/mtrand.pyx @@ -4226,7 +4226,7 @@ cdef class RandomState: 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) diff --git a/numpy/random/tests/test_random.py b/numpy/random/tests/test_random.py index 3c0e5d422..8b5d083a3 100644 --- a/numpy/random/tests/test_random.py +++ b/numpy/random/tests/test_random.py @@ -34,6 +34,12 @@ class TestRegression(TestCase): 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): |