summaryrefslogtreecommitdiff
path: root/numpy/random/tests
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2020-01-05 00:53:30 -0500
committerWarren Weckesser <warren.weckesser@gmail.com>2020-01-05 00:53:30 -0500
commitc31cc36a8a814ed4844a2a553454185601914a5a (patch)
treeadb28a762dc0985eed669db75b564b3f5c3bfbcc /numpy/random/tests
parentc1f1bc9ce8e4e2936e80d9bfafc3d8e03237a84b (diff)
downloadnumpy-c31cc36a8a814ed4844a2a553454185601914a5a.tar.gz
MAINT: Remove implicit inheritance from object class (#15236)
Inheriting from object was necessary for Python 2 compatibility to use new-style classes. In Python 3, this is unnecessary as there are no old-style classes. Dropping the object is more idiomatic Python.
Diffstat (limited to 'numpy/random/tests')
-rw-r--r--numpy/random/tests/test_direct.py4
-rw-r--r--numpy/random/tests/test_generator_mt19937.py20
-rw-r--r--numpy/random/tests/test_generator_mt19937_regressions.py4
-rw-r--r--numpy/random/tests/test_random.py18
-rw-r--r--numpy/random/tests/test_randomstate.py18
-rw-r--r--numpy/random/tests/test_randomstate_regression.py4
-rw-r--r--numpy/random/tests/test_regression.py4
-rw-r--r--numpy/random/tests/test_smoke.py2
8 files changed, 37 insertions, 37 deletions
diff --git a/numpy/random/tests/test_direct.py b/numpy/random/tests/test_direct.py
index 9f77f0ad2..4fa69a402 100644
--- a/numpy/random/tests/test_direct.py
+++ b/numpy/random/tests/test_direct.py
@@ -145,7 +145,7 @@ def test_seedsequence():
assert len(dummy.spawn(10)) == 10
-class Base(object):
+class Base:
dtype = np.uint64
data2 = data1 = {}
@@ -410,7 +410,7 @@ class TestSFC64(Base):
cls.invalid_init_values = [(-1,)]
-class TestDefaultRNG(object):
+class TestDefaultRNG:
def test_seed(self):
for args in [(), (None,), (1234,), ([1234, 5678],)]:
rg = default_rng(*args)
diff --git a/numpy/random/tests/test_generator_mt19937.py b/numpy/random/tests/test_generator_mt19937.py
index 5b3d5f08a..6f4407373 100644
--- a/numpy/random/tests/test_generator_mt19937.py
+++ b/numpy/random/tests/test_generator_mt19937.py
@@ -19,7 +19,7 @@ def endpoint(request):
return request.param
-class TestSeed(object):
+class TestSeed:
def test_scalar(self):
s = Generator(MT19937(0))
assert_equal(s.integers(1000), 479)
@@ -55,7 +55,7 @@ class TestSeed(object):
assert_raises(ValueError, Generator, 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].
@@ -70,7 +70,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])
@@ -116,7 +116,7 @@ class TestMultinomial(object):
assert_array_equal(non_contig, contig)
-class TestMultivariateHypergeometric(object):
+class TestMultivariateHypergeometric:
def setup(self):
self.seed = 8675309
@@ -250,7 +250,7 @@ class TestMultivariateHypergeometric(object):
assert_array_equal(sample, expected)
-class TestSetState(object):
+class TestSetState:
def setup(self):
self.seed = 1234567890
self.rg = Generator(MT19937(self.seed))
@@ -284,7 +284,7 @@ class TestSetState(object):
self.rg.negative_binomial(0.5, 0.5)
-class TestIntegers(object):
+class TestIntegers:
rfunc = random.integers
# valid integer/boolean types
@@ -637,7 +637,7 @@ class TestIntegers(object):
assert chi2 < chi2max
-class TestRandomDist(object):
+class TestRandomDist:
# Make sure the random distribution returns the correct value for a
# given seed
@@ -1565,7 +1565,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):
@@ -2117,7 +2117,7 @@ class TestBroadcast(object):
assert_array_equal(actual, desired)
-class TestThread(object):
+class TestThread:
# make sure each state produces the same sequence even in threads
def setup(self):
self.seeds = range(4)
@@ -2164,7 +2164,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])
diff --git a/numpy/random/tests/test_generator_mt19937_regressions.py b/numpy/random/tests/test_generator_mt19937_regressions.py
index 7ca8b9f3c..fb0aac335 100644
--- a/numpy/random/tests/test_generator_mt19937_regressions.py
+++ b/numpy/random/tests/test_generator_mt19937_regressions.py
@@ -7,7 +7,7 @@ from numpy.random import Generator, MT19937
mt19937 = Generator(MT19937())
-class TestRegression(object):
+class TestRegression:
def test_VonMises_range(self):
# Make sure generated random variables are in [-pi, pi].
@@ -136,7 +136,7 @@ class TestRegression(object):
assert_array_equal(perm, np.array([2, 0, 1]))
assert_array_equal(orig, np.arange(3).view(N))
- class M(object):
+ class M:
a = np.arange(5)
def __array__(self):
diff --git a/numpy/random/tests/test_random.py b/numpy/random/tests/test_random.py
index 81d74650e..a9aa15083 100644
--- a/numpy/random/tests/test_random.py
+++ b/numpy/random/tests/test_random.py
@@ -10,7 +10,7 @@ from numpy import random
import sys
-class TestSeed(object):
+class TestSeed:
def test_scalar(self):
s = np.random.RandomState(0)
assert_equal(s.randint(1000), 684)
@@ -49,7 +49,7 @@ class TestSeed(object):
[4, 5, 6]])
-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].
@@ -64,7 +64,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])
@@ -92,7 +92,7 @@ class TestMultinomial(object):
float(1))
-class TestSetState(object):
+class TestSetState:
def setup(self):
self.seed = 1234567890
self.prng = random.RandomState(self.seed)
@@ -140,7 +140,7 @@ class TestSetState(object):
self.prng.negative_binomial(0.5, 0.5)
-class TestRandint(object):
+class TestRandint:
rfunc = np.random.randint
@@ -278,7 +278,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
@@ -973,7 +973,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):
@@ -1543,7 +1543,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)
@@ -1587,7 +1587,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])
diff --git a/numpy/random/tests/test_randomstate.py b/numpy/random/tests/test_randomstate.py
index c12b685ad..ebe8558ba 100644
--- a/numpy/random/tests/test_randomstate.py
+++ b/numpy/random/tests/test_randomstate.py
@@ -61,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)
@@ -108,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].
@@ -123,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])
@@ -168,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)
@@ -255,7 +255,7 @@ class TestSetState(object):
assert repr(self.random_state).startswith('RandomState(MT19937)')
-class TestRandint(object):
+class TestRandint:
rfunc = random.randint
@@ -392,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
@@ -1245,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):
@@ -1832,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)
@@ -1879,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])
diff --git a/numpy/random/tests/test_randomstate_regression.py b/numpy/random/tests/test_randomstate_regression.py
index bdc2214b6..3be9edf02 100644
--- a/numpy/random/tests/test_randomstate_regression.py
+++ b/numpy/random/tests/test_randomstate_regression.py
@@ -11,7 +11,7 @@ import numpy as np
from numpy import random
-class TestRegression(object):
+class TestRegression:
def test_VonMises_range(self):
# Make sure generated random variables are in [-pi, pi].
@@ -147,7 +147,7 @@ class TestRegression(object):
assert_array_equal(perm, np.array([0, 2, 1]))
assert_array_equal(orig, np.arange(3).view(N))
- class M(object):
+ class M:
a = np.arange(5)
def __array__(self):
diff --git a/numpy/random/tests/test_regression.py b/numpy/random/tests/test_regression.py
index e70505cec..7d77a31d8 100644
--- a/numpy/random/tests/test_regression.py
+++ b/numpy/random/tests/test_regression.py
@@ -7,7 +7,7 @@ from numpy.compat import long
import numpy as np
-class TestRegression(object):
+class TestRegression:
def test_VonMises_range(self):
# Make sure generated random variables are in [-pi, pi].
@@ -143,7 +143,7 @@ class TestRegression(object):
assert_array_equal(perm, np.array([0, 2, 1]))
assert_array_equal(orig, np.arange(3).view(N))
- class M(object):
+ class M:
a = np.arange(5)
def __array__(self):
diff --git a/numpy/random/tests/test_smoke.py b/numpy/random/tests/test_smoke.py
index cdaac5ebb..ebfc6825e 100644
--- a/numpy/random/tests/test_smoke.py
+++ b/numpy/random/tests/test_smoke.py
@@ -91,7 +91,7 @@ def warmup(rg, n=None):
rg.random(n, dtype=np.float32)
-class RNG(object):
+class RNG:
@classmethod
def setup_class(cls):
# Overridden in test classes. Place holder to silence IDE noise