summaryrefslogtreecommitdiff
path: root/numpy/random/tests/test_randomstate.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/random/tests/test_randomstate.py')
-rw-r--r--numpy/random/tests/test_randomstate.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/numpy/random/tests/test_randomstate.py b/numpy/random/tests/test_randomstate.py
index a0edc5c23..ebe8558ba 100644
--- a/numpy/random/tests/test_randomstate.py
+++ b/numpy/random/tests/test_randomstate.py
@@ -11,7 +11,8 @@ from numpy.testing import (
suppress_warnings
)
-from numpy.random import MT19937, PCG64, mtrand as random
+from numpy.random import MT19937, PCG64
+from numpy import random
INT_FUNCS = {'binomial': (100.0, 0.6),
'geometric': (.5,),
@@ -60,7 +61,7 @@ def assert_mt19937_state_equal(a, b):
assert_equal(a['gauss'], b['gauss'])
-class TestSeed(object):
+class TestSeed:
def test_scalar(self):
s = random.RandomState(0)
assert_equal(s.randint(1000), 684)
@@ -107,7 +108,7 @@ class TestSeed(object):
assert_raises(ValueError, random.RandomState, MT19937)
-class TestBinomial(object):
+class TestBinomial:
def test_n_zero(self):
# Tests the corner case of n == 0 for the binomial distribution.
# binomial(0, p) should be zero for any p in [0, 1].
@@ -122,7 +123,7 @@ class TestBinomial(object):
assert_raises(ValueError, random.binomial, 1, np.nan)
-class TestMultinomial(object):
+class TestMultinomial:
def test_basic(self):
random.multinomial(100, [0.2, 0.8])
@@ -167,7 +168,7 @@ class TestMultinomial(object):
assert_array_equal(non_contig, contig)
-class TestSetState(object):
+class TestSetState:
def setup(self):
self.seed = 1234567890
self.random_state = random.RandomState(self.seed)
@@ -228,7 +229,7 @@ class TestSetState(object):
new_state = ('Unknown', ) + state[1:]
assert_raises(ValueError, self.random_state.set_state, new_state)
assert_raises(TypeError, self.random_state.set_state,
- np.array(new_state, dtype=np.object))
+ np.array(new_state, dtype=object))
state = self.random_state.get_state(legacy=False)
del state['bit_generator']
assert_raises(ValueError, self.random_state.set_state, state)
@@ -254,7 +255,7 @@ class TestSetState(object):
assert repr(self.random_state).startswith('RandomState(MT19937)')
-class TestRandint(object):
+class TestRandint:
rfunc = random.randint
@@ -381,7 +382,7 @@ class TestRandint(object):
sample = self.rfunc(lbnd, ubnd, dtype=dt)
assert_equal(sample.dtype, np.dtype(dt))
- for dt in (bool, int, np.long):
+ for dt in (bool, int, np.compat.long):
lbnd = 0 if dt is bool else np.iinfo(dt).min
ubnd = 2 if dt is bool else np.iinfo(dt).max + 1
@@ -391,7 +392,7 @@ class TestRandint(object):
assert_equal(type(sample), dt)
-class TestRandomDist(object):
+class TestRandomDist:
# Make sure the random distribution returns the correct value for a
# given seed
@@ -454,7 +455,7 @@ class TestRandomDist(object):
random.seed(self.seed)
rs = random.RandomState(self.seed)
actual = rs.tomaxint(size=(3, 2))
- if np.iinfo(np.int).max == 2147483647:
+ if np.iinfo(int).max == 2147483647:
desired = np.array([[1328851649, 731237375],
[1270502067, 320041495],
[1908433478, 499156889]], dtype=np.int64)
@@ -1244,7 +1245,7 @@ class TestRandomDist(object):
assert_array_equal(actual, desired)
-class TestBroadcast(object):
+class TestBroadcast:
# tests that functions that broadcast behave
# correctly when presented with non-scalar arguments
def setup(self):
@@ -1831,7 +1832,7 @@ class TestBroadcast(object):
assert_raises(ValueError, logseries, bad_p_two * 3)
-class TestThread(object):
+class TestThread:
# make sure each state produces the same sequence even in threads
def setup(self):
self.seeds = range(4)
@@ -1878,7 +1879,7 @@ class TestThread(object):
# See Issue #4263
-class TestSingleEltArrayInput(object):
+class TestSingleEltArrayInput:
def setup(self):
self.argOne = np.array([2])
self.argTwo = np.array([3])