summaryrefslogtreecommitdiff
path: root/numpy/lib
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/lib
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/lib')
-rw-r--r--numpy/lib/_datasource.py4
-rw-r--r--numpy/lib/_iotools.py6
-rw-r--r--numpy/lib/arrayterator.py2
-rw-r--r--numpy/lib/function_base.py2
-rw-r--r--numpy/lib/index_tricks.py10
-rw-r--r--numpy/lib/mixins.py2
-rw-r--r--numpy/lib/npyio.py6
-rw-r--r--numpy/lib/polynomial.py2
-rw-r--r--numpy/lib/stride_tricks.py2
-rw-r--r--numpy/lib/tests/test__datasource.py12
-rw-r--r--numpy/lib/tests/test__iotools.py8
-rw-r--r--numpy/lib/tests/test_arraypad.py24
-rw-r--r--numpy/lib/tests/test_arraysetops.py6
-rw-r--r--numpy/lib/tests/test_financial.py2
-rw-r--r--numpy/lib/tests/test_function_base.py90
-rw-r--r--numpy/lib/tests/test_histograms.py6
-rw-r--r--numpy/lib/tests/test_index_tricks.py16
-rw-r--r--numpy/lib/tests/test_io.py16
-rw-r--r--numpy/lib/tests/test_mixins.py4
-rw-r--r--numpy/lib/tests/test_nanfunctions.py14
-rw-r--r--numpy/lib/tests/test_polynomial.py2
-rw-r--r--numpy/lib/tests/test_recfunctions.py16
-rw-r--r--numpy/lib/tests/test_regression.py2
-rw-r--r--numpy/lib/tests/test_shape_base.py32
-rw-r--r--numpy/lib/tests/test_twodim_base.py20
-rw-r--r--numpy/lib/tests/test_type_check.py36
-rw-r--r--numpy/lib/tests/test_ufunclike.py2
-rw-r--r--numpy/lib/tests/test_utils.py2
-rw-r--r--numpy/lib/user_array.py2
-rw-r--r--numpy/lib/utils.py2
30 files changed, 175 insertions, 175 deletions
diff --git a/numpy/lib/_datasource.py b/numpy/lib/_datasource.py
index 8d1b8339a..aa793958e 100644
--- a/numpy/lib/_datasource.py
+++ b/numpy/lib/_datasource.py
@@ -139,7 +139,7 @@ def _python2_gzipopen(fn, mode, encoding, newline):
# deferring the import of lzma, bz2 and gzip until needed
# TODO: .zip support, .tar support?
-class _FileOpeners(object):
+class _FileOpeners:
"""
Container for different methods to open (un-)compressed files.
@@ -268,7 +268,7 @@ def open(path, mode='r', destpath=os.curdir, encoding=None, newline=None):
@set_module('numpy')
-class DataSource(object):
+class DataSource:
"""
DataSource(destpath='.')
diff --git a/numpy/lib/_iotools.py b/numpy/lib/_iotools.py
index f612cbe94..dd6e9ec66 100644
--- a/numpy/lib/_iotools.py
+++ b/numpy/lib/_iotools.py
@@ -130,7 +130,7 @@ def flatten_dtype(ndtype, flatten_base=False):
return types
-class LineSplitter(object):
+class LineSplitter:
"""
Object to split a string at a given delimiter or at given places.
@@ -231,7 +231,7 @@ class LineSplitter(object):
return self._handyman(_decode_line(line, self.encoding))
-class NameValidator(object):
+class NameValidator:
"""
Object to validate a list of strings to use as field names.
@@ -454,7 +454,7 @@ class ConversionWarning(UserWarning):
pass
-class StringConverter(object):
+class StringConverter:
"""
Factory class for function transforming a string into another object
(int, float).
diff --git a/numpy/lib/arrayterator.py b/numpy/lib/arrayterator.py
index 0727c7a3e..15b0f8aa9 100644
--- a/numpy/lib/arrayterator.py
+++ b/numpy/lib/arrayterator.py
@@ -15,7 +15,7 @@ from numpy.compat import long
__all__ = ['Arrayterator']
-class Arrayterator(object):
+class Arrayterator:
"""
Buffered iterator for big arrays.
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 3b0a6783b..6c7dfbfd3 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -1870,7 +1870,7 @@ def _create_arrays(broadcast_shape, dim_sizes, list_of_core_dims, dtypes):
@set_module('numpy')
-class vectorize(object):
+class vectorize:
"""
vectorize(pyfunc, otypes=None, doc=None, excluded=None, cache=False,
signature=None)
diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py
index f6a6f922c..0560bd36d 100644
--- a/numpy/lib/index_tricks.py
+++ b/numpy/lib/index_tricks.py
@@ -105,7 +105,7 @@ def ix_(*args):
out.append(new)
return tuple(out)
-class nd_grid(object):
+class nd_grid:
"""
Construct a multi-dimensional "meshgrid".
@@ -297,7 +297,7 @@ class OGridClass(nd_grid):
ogrid = OGridClass()
-class AxisConcatenator(object):
+class AxisConcatenator:
"""
Translates slice objects to concatenation along an axis.
@@ -550,7 +550,7 @@ c_ = CClass()
@set_module('numpy')
-class ndenumerate(object):
+class ndenumerate:
"""
Multidimensional index iterator.
@@ -601,7 +601,7 @@ class ndenumerate(object):
@set_module('numpy')
-class ndindex(object):
+class ndindex:
"""
An N-dimensional iterator object to index arrays.
@@ -679,7 +679,7 @@ class ndindex(object):
#
#
-class IndexExpression(object):
+class IndexExpression:
"""
A nicer way to build up index tuples for arrays.
diff --git a/numpy/lib/mixins.py b/numpy/lib/mixins.py
index dd17adb41..d4811b94d 100644
--- a/numpy/lib/mixins.py
+++ b/numpy/lib/mixins.py
@@ -58,7 +58,7 @@ def _unary_method(ufunc, name):
return func
-class NDArrayOperatorsMixin(object):
+class NDArrayOperatorsMixin:
"""Mixin defining all operator special methods using __array_ufunc__.
This class implements the special methods for almost all of Python's
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index c85db2922..c47e388c0 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -53,7 +53,7 @@ array_function_dispatch = functools.partial(
overrides.array_function_dispatch, module='numpy')
-class BagObj(object):
+class BagObj:
"""
BagObj(obj)
@@ -67,7 +67,7 @@ class BagObj(object):
Examples
--------
>>> from numpy.lib.npyio import BagObj as BO
- >>> class BagDemo(object):
+ >>> class BagDemo:
... def __getitem__(self, key): # An instance of BagObj(BagDemo)
... # will call this method when any
... # attribute look-up is required
@@ -1334,7 +1334,7 @@ def savetxt(fname, X, fmt='%.18e', delimiter=' ', newline='\n', header='',
fmt = asstr(fmt)
delimiter = asstr(delimiter)
- class WriteWrap(object):
+ class WriteWrap:
"""Convert to unicode in py2 or to bytes on bytestream inputs.
"""
diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py
index c2b615e0e..5a0fa5431 100644
--- a/numpy/lib/polynomial.py
+++ b/numpy/lib/polynomial.py
@@ -1005,7 +1005,7 @@ def _raise_power(astr, wrap=70):
@set_module('numpy')
-class poly1d(object):
+class poly1d:
"""
A one-dimensional polynomial class.
diff --git a/numpy/lib/stride_tricks.py b/numpy/lib/stride_tricks.py
index b65706dd5..9c9da2974 100644
--- a/numpy/lib/stride_tricks.py
+++ b/numpy/lib/stride_tricks.py
@@ -11,7 +11,7 @@ from numpy.core.overrides import array_function_dispatch
__all__ = ['broadcast_to', 'broadcast_arrays']
-class DummyArray(object):
+class DummyArray:
"""Dummy object that just exists to hang __array_interface__ dictionaries
and possibly keep alive a reference to a base array.
"""
diff --git a/numpy/lib/tests/test__datasource.py b/numpy/lib/tests/test__datasource.py
index e7c14b807..fdd22347d 100644
--- a/numpy/lib/tests/test__datasource.py
+++ b/numpy/lib/tests/test__datasource.py
@@ -94,7 +94,7 @@ def invalid_httpfile():
return http_fakefile
-class TestDataSourceOpen(object):
+class TestDataSourceOpen:
def setup(self):
self.tmpdir = mkdtemp()
self.ds = datasource.DataSource(self.tmpdir)
@@ -181,7 +181,7 @@ class TestDataSourceOpen(object):
assert_equal(magic_line, result)
-class TestDataSourceExists(object):
+class TestDataSourceExists:
def setup(self):
self.tmpdir = mkdtemp()
self.ds = datasource.DataSource(self.tmpdir)
@@ -211,7 +211,7 @@ class TestDataSourceExists(object):
assert_equal(self.ds.exists(tmpfile), False)
-class TestDataSourceAbspath(object):
+class TestDataSourceAbspath:
def setup(self):
self.tmpdir = os.path.abspath(mkdtemp())
self.ds = datasource.DataSource(self.tmpdir)
@@ -276,7 +276,7 @@ class TestDataSourceAbspath(object):
os.sep = orig_os_sep
-class TestRepositoryAbspath(object):
+class TestRepositoryAbspath:
def setup(self):
self.tmpdir = os.path.abspath(mkdtemp())
self.repos = datasource.Repository(valid_baseurl(), self.tmpdir)
@@ -309,7 +309,7 @@ class TestRepositoryAbspath(object):
os.sep = orig_os_sep
-class TestRepositoryExists(object):
+class TestRepositoryExists:
def setup(self):
self.tmpdir = mkdtemp()
self.repos = datasource.Repository(valid_baseurl(), self.tmpdir)
@@ -342,7 +342,7 @@ class TestRepositoryExists(object):
assert_(self.repos.exists(tmpfile))
-class TestOpenFunc(object):
+class TestOpenFunc:
def setup(self):
self.tmpdir = mkdtemp()
diff --git a/numpy/lib/tests/test__iotools.py b/numpy/lib/tests/test__iotools.py
index 24c2533e8..1d69d869e 100644
--- a/numpy/lib/tests/test__iotools.py
+++ b/numpy/lib/tests/test__iotools.py
@@ -12,7 +12,7 @@ from numpy.lib._iotools import (
from numpy.compat import unicode
-class TestLineSplitter(object):
+class TestLineSplitter:
"Tests the LineSplitter class."
def test_no_delimiter(self):
@@ -81,7 +81,7 @@ class TestLineSplitter(object):
# -----------------------------------------------------------------------------
-class TestNameValidator(object):
+class TestNameValidator:
def test_case_sensitivity(self):
"Test case sensitivity"
@@ -139,7 +139,7 @@ def _bytes_to_date(s):
return date(*time.strptime(s, "%Y-%m-%d")[:3])
-class TestStringConverter(object):
+class TestStringConverter:
"Test StringConverter"
def test_creation(self):
@@ -264,7 +264,7 @@ class TestStringConverter(object):
assert_(converter(val) == 9223372043271415339)
-class TestMiscFunctions(object):
+class TestMiscFunctions:
def test_has_nested_dtype(self):
"Test has_nested_dtype"
diff --git a/numpy/lib/tests/test_arraypad.py b/numpy/lib/tests/test_arraypad.py
index 6ae3ef5c0..cd75b4ac4 100644
--- a/numpy/lib/tests/test_arraypad.py
+++ b/numpy/lib/tests/test_arraypad.py
@@ -29,7 +29,7 @@ _all_modes = {
}
-class TestAsPairs(object):
+class TestAsPairs:
def test_single_value(self):
"""Test casting for a single value."""
expected = np.array([[3, 3]] * 10)
@@ -112,7 +112,7 @@ class TestAsPairs(object):
_as_pairs(np.ones((2, 3)), 3)
-class TestConditionalShortcuts(object):
+class TestConditionalShortcuts:
@pytest.mark.parametrize("mode", _all_modes.keys())
def test_zero_padding_shortcuts(self, mode):
test = np.arange(120).reshape(4, 5, 6)
@@ -134,7 +134,7 @@ class TestConditionalShortcuts(object):
np.pad(test, pad_amt, mode=mode, stat_length=30))
-class TestStatistic(object):
+class TestStatistic:
def test_check_mean_stat_length(self):
a = np.arange(100).astype('f')
a = np.pad(a, ((25, 20), ), 'mean', stat_length=((2, 3), ))
@@ -496,7 +496,7 @@ class TestStatistic(object):
np.pad([1., 2.], 1, mode, stat_length=(1, 0))
-class TestConstant(object):
+class TestConstant:
def test_check_constant(self):
a = np.arange(100)
a = np.pad(a, (25, 20), 'constant', constant_values=(10, 20))
@@ -675,7 +675,7 @@ class TestConstant(object):
assert result.shape == (3, 4, 4)
-class TestLinearRamp(object):
+class TestLinearRamp:
def test_check_simple(self):
a = np.arange(100).astype('f')
a = np.pad(a, (25, 20), 'linear_ramp', end_values=(4, 5))
@@ -760,7 +760,7 @@ class TestLinearRamp(object):
assert_equal(result, expected)
-class TestReflect(object):
+class TestReflect:
def test_check_simple(self):
a = np.arange(100)
a = np.pad(a, (25, 20), 'reflect')
@@ -870,7 +870,7 @@ class TestReflect(object):
assert_array_equal(a, b)
-class TestEmptyArray(object):
+class TestEmptyArray:
"""Check how padding behaves on arrays with an empty dimension."""
@pytest.mark.parametrize(
@@ -894,7 +894,7 @@ class TestEmptyArray(object):
assert result.shape == (8, 0, 4)
-class TestSymmetric(object):
+class TestSymmetric:
def test_check_simple(self):
a = np.arange(100)
a = np.pad(a, (25, 20), 'symmetric')
@@ -1028,7 +1028,7 @@ class TestSymmetric(object):
assert_array_equal(a, b)
-class TestWrap(object):
+class TestWrap:
def test_check_simple(self):
a = np.arange(100)
a = np.pad(a, (25, 20), 'wrap')
@@ -1142,7 +1142,7 @@ class TestWrap(object):
assert_array_equal(np.r_[a, a, a, a][:-3], b)
-class TestEdge(object):
+class TestEdge:
def test_check_simple(self):
a = np.arange(12)
a = np.reshape(a, (4, 3))
@@ -1181,7 +1181,7 @@ class TestEdge(object):
assert_array_equal(padded, expected)
-class TestEmpty(object):
+class TestEmpty:
def test_simple(self):
arr = np.arange(24).reshape(4, 6)
result = np.pad(arr, [(2, 3), (3, 1)], mode="empty")
@@ -1229,7 +1229,7 @@ def test_object_input(mode):
assert_array_equal(np.pad(a, pad_amt, mode=mode), b)
-class TestPadWidth(object):
+class TestPadWidth:
@pytest.mark.parametrize("pad_width", [
(4, 5, 6, 7),
((1,), (2,), (3,)),
diff --git a/numpy/lib/tests/test_arraysetops.py b/numpy/lib/tests/test_arraysetops.py
index 992a37cef..851fd31ea 100644
--- a/numpy/lib/tests/test_arraysetops.py
+++ b/numpy/lib/tests/test_arraysetops.py
@@ -12,7 +12,7 @@ import pytest
-class TestSetOps(object):
+class TestSetOps:
def test_intersect1d(self):
# unique inputs
@@ -34,7 +34,7 @@ class TestSetOps(object):
def test_intersect1d_array_like(self):
# See gh-11772
- class Test(object):
+ class Test:
def __array__(self):
return np.arange(3)
@@ -413,7 +413,7 @@ class TestSetOps(object):
assert_array_equal(c1, c2)
-class TestUnique(object):
+class TestUnique:
def test_unique_1d(self):
diff --git a/numpy/lib/tests/test_financial.py b/numpy/lib/tests/test_financial.py
index e7a71c722..26e79bc06 100644
--- a/numpy/lib/tests/test_financial.py
+++ b/numpy/lib/tests/test_financial.py
@@ -16,7 +16,7 @@ def filter_deprecation(func):
return newfunc
-class TestFinancial(object):
+class TestFinancial:
@filter_deprecation
def test_npv_irr_congruence(self):
# IRR is defined as the rate required for the present value of a
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 42a8c591c..dfce2d55d 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -42,7 +42,7 @@ def _make_complex(real, imag):
return ret
-class TestRot90(object):
+class TestRot90:
def test_basic(self):
assert_raises(ValueError, rot90, np.ones(4))
assert_raises(ValueError, rot90, np.ones((2,2,2)), axes=(0,1,2))
@@ -110,7 +110,7 @@ class TestRot90(object):
rot90(a_rot90_20, k=k-1, axes=(2, 0)))
-class TestFlip(object):
+class TestFlip:
def test_axes(self):
assert_raises(np.AxisError, np.flip, np.ones(4), axis=1)
@@ -213,7 +213,7 @@ class TestFlip(object):
assert_equal(np.flip(a, axis=(1, 2)), c)
-class TestAny(object):
+class TestAny:
def test_basic(self):
y1 = [0, 0, 1, 0]
@@ -230,7 +230,7 @@ class TestAny(object):
assert_array_equal(np.sometrue(y1, axis=1), [0, 1, 1])
-class TestAll(object):
+class TestAll:
def test_basic(self):
y1 = [0, 1, 1, 0]
@@ -248,7 +248,7 @@ class TestAll(object):
assert_array_equal(np.alltrue(y1, axis=1), [0, 0, 1])
-class TestCopy(object):
+class TestCopy:
def test_basic(self):
a = np.array([[1, 2], [3, 4]])
@@ -276,7 +276,7 @@ class TestCopy(object):
assert_(a_fort_copy.flags.f_contiguous)
-class TestAverage(object):
+class TestAverage:
def test_basic(self):
y1 = np.array([1, 2, 3])
@@ -377,7 +377,7 @@ class TestAverage(object):
w /= w.sum()
assert_almost_equal(a.mean(0), average(a, weights=w))
-class TestSelect(object):
+class TestSelect:
choices = [np.array([1, 2, 3]),
np.array([4, 5, 6]),
np.array([7, 8, 9])]
@@ -439,7 +439,7 @@ class TestSelect(object):
select(conditions, choices)
-class TestInsert(object):
+class TestInsert:
def test_basic(self):
a = [1, 2, 3]
@@ -540,7 +540,7 @@ class TestInsert(object):
assert_array_equal(b[[0, 3]], np.array(val, dtype=b.dtype))
-class TestAmax(object):
+class TestAmax:
def test_basic(self):
a = [3, 4, 5, 10, -3, -5, 6.0]
@@ -552,7 +552,7 @@ class TestAmax(object):
assert_equal(np.amax(b, axis=1), [9.0, 10.0, 8.0])
-class TestAmin(object):
+class TestAmin:
def test_basic(self):
a = [3, 4, 5, 10, -3, -5, 6.0]
@@ -564,7 +564,7 @@ class TestAmin(object):
assert_equal(np.amin(b, axis=1), [3.0, 4.0, 2.0])
-class TestPtp(object):
+class TestPtp:
def test_basic(self):
a = np.array([3, 4, 5, 10, -3, -5, 6.0])
@@ -579,7 +579,7 @@ class TestPtp(object):
assert_equal(b.ptp(axis=(0,1), keepdims=True), [[8.0]])
-class TestCumsum(object):
+class TestCumsum:
def test_basic(self):
ba = [1, 2, 10, 11, 6, 5, 4]
@@ -602,7 +602,7 @@ class TestCumsum(object):
assert_array_equal(np.cumsum(a2, axis=1), tgt)
-class TestProd(object):
+class TestProd:
def test_basic(self):
ba = [1, 2, 10, 11, 6, 5, 4]
@@ -622,7 +622,7 @@ class TestProd(object):
np.array([24, 1890, 600], ctype))
-class TestCumprod(object):
+class TestCumprod:
def test_basic(self):
ba = [1, 2, 10, 11, 6, 5, 4]
@@ -649,7 +649,7 @@ class TestCumprod(object):
[10, 30, 120, 600]], ctype))
-class TestDiff(object):
+class TestDiff:
def test_basic(self):
x = [1, 4, 6, 7, 12]
@@ -789,7 +789,7 @@ class TestDiff(object):
assert_raises(np.AxisError, diff, x, append=0, axis=3)
-class TestDelete(object):
+class TestDelete:
def setup(self):
self.a = np.arange(5)
@@ -864,7 +864,7 @@ class TestDelete(object):
assert_equal(m.flags.f_contiguous, k.flags.f_contiguous)
-class TestGradient(object):
+class TestGradient:
def test_basic(self):
v = [[1, 1], [3, 4]]
@@ -1116,7 +1116,7 @@ class TestGradient(object):
assert_array_equal(dfdx, [0.5, 0.5])
-class TestAngle(object):
+class TestAngle:
def test_basic(self):
x = [1 + 3j, np.sqrt(2) / 2.0 + 1j * np.sqrt(2) / 2,
@@ -1142,7 +1142,7 @@ class TestAngle(object):
assert_equal(actual, expected)
-class TestTrimZeros(object):
+class TestTrimZeros:
"""
Only testing for integer splits.
@@ -1165,7 +1165,7 @@ class TestTrimZeros(object):
assert_array_equal(res, np.array([1, 0, 2, 3, 0, 4]))
-class TestExtins(object):
+class TestExtins:
def test_basic(self):
a = np.array([1, 3, 2, 1, 2, 3, 3])
@@ -1204,7 +1204,7 @@ class TestExtins(object):
assert_array_equal(a, ac)
-class TestVectorize(object):
+class TestVectorize:
def test_simple(self):
def addsubtract(a, b):
@@ -1536,8 +1536,8 @@ class TestVectorize(object):
f(x)
-class TestLeaks(object):
- class A(object):
+class TestLeaks:
+ class A:
iters = 20
def bound(self, *args):
@@ -1579,7 +1579,7 @@ class TestLeaks(object):
finally:
gc.enable()
-class TestDigitize(object):
+class TestDigitize:
def test_forward(self):
x = np.arange(-6, 5)
@@ -1664,7 +1664,7 @@ class TestDigitize(object):
assert_equal(np.digitize(x, [x + 1, x - 1]), 1)
-class TestUnwrap(object):
+class TestUnwrap:
def test_simple(self):
# check that unwrap removes jumps greater that 2*pi
@@ -1673,7 +1673,7 @@ class TestUnwrap(object):
assert_(np.all(diff(unwrap(rand(10) * 100)) < np.pi))
-class TestFilterwindows(object):
+class TestFilterwindows:
def test_hanning(self):
# check symmetry
@@ -1704,7 +1704,7 @@ class TestFilterwindows(object):
assert_almost_equal(np.sum(w, axis=0), 3.7800, 4)
-class TestTrapz(object):
+class TestTrapz:
def test_simple(self):
x = np.arange(-10, 10, .1)
@@ -1766,7 +1766,7 @@ class TestTrapz(object):
assert_almost_equal(trapz(y, xm), r)
-class TestSinc(object):
+class TestSinc:
def test_simple(self):
assert_(sinc(0) == 1)
@@ -1783,7 +1783,7 @@ class TestSinc(object):
assert_array_equal(y1, y3)
-class TestUnique(object):
+class TestUnique:
def test_simple(self):
x = np.array([4, 3, 2, 1, 1, 2, 3, 4, 0])
@@ -1795,7 +1795,7 @@ class TestUnique(object):
assert_(np.all(unique(x) == [1 + 1j, 1 + 10j, 5 + 6j, 10]))
-class TestCheckFinite(object):
+class TestCheckFinite:
def test_simple(self):
a = [1, 2, 3]
@@ -1812,7 +1812,7 @@ class TestCheckFinite(object):
assert_(a.dtype == np.float64)
-class TestCorrCoef(object):
+class TestCorrCoef:
A = np.array(
[[0.15391142, 0.18045767, 0.14197213],
[0.70461506, 0.96474128, 0.27906989],
@@ -1897,7 +1897,7 @@ class TestCorrCoef(object):
assert_(np.all(np.abs(c) <= 1.0))
-class TestCov(object):
+class TestCov:
x1 = np.array([[0, 2], [1, 1], [2, 0]]).T
res1 = np.array([[1., -1.], [-1., 1.]])
x2 = np.array([0.0, 1.0, 2.0], ndmin=2)
@@ -1997,7 +1997,7 @@ class TestCov(object):
self.res1)
-class Test_I0(object):
+class Test_I0:
def test_simple(self):
assert_almost_equal(
@@ -2043,7 +2043,7 @@ class Test_I0(object):
assert_array_equal(exp, res)
-class TestKaiser(object):
+class TestKaiser:
def test_simple(self):
assert_(np.isfinite(kaiser(1, 1.0)))
@@ -2062,7 +2062,7 @@ class TestKaiser(object):
kaiser(3, 4)
-class TestMsort(object):
+class TestMsort:
def test_simple(self):
A = np.array([[0.44567325, 0.79115165, 0.54900530],
@@ -2075,7 +2075,7 @@ class TestMsort(object):
[0.64864341, 0.79115165, 0.96098397]]))
-class TestMeshgrid(object):
+class TestMeshgrid:
def test_simple(self):
[X, Y] = meshgrid([1, 2, 3], [4, 5, 6, 7])
@@ -2164,7 +2164,7 @@ class TestMeshgrid(object):
assert_equal(x[1, :], X)
-class TestPiecewise(object):
+class TestPiecewise:
def test_simple(self):
# Condition is single bool list
@@ -2256,7 +2256,7 @@ class TestPiecewise(object):
[3., 3., 1.]]))
-class TestBincount(object):
+class TestBincount:
def test_simple(self):
y = np.bincount(np.arange(4))
@@ -2343,7 +2343,7 @@ class TestBincount(object):
assert_equal(sys.getrefcount(np.dtype(np.double)), double_refcount)
-class TestInterp(object):
+class TestInterp:
def test_exceptions(self):
assert_raises(ValueError, interp, 0, [], [])
@@ -2542,7 +2542,7 @@ def compare_results(res, desired):
assert_array_equal(res[i], desired[i])
-class TestPercentile(object):
+class TestPercentile:
def test_basic(self):
x = np.arange(8) * 0.5
@@ -2963,7 +2963,7 @@ class TestPercentile(object):
a, [0.3, 0.6], (0, 2), interpolation='nearest'), b)
-class TestQuantile(object):
+class TestQuantile:
# most of this is already tested by TestPercentile
def test_basic(self):
@@ -3005,7 +3005,7 @@ class TestQuantile(object):
assert_array_equal(p, p0)
-class TestMedian(object):
+class TestMedian:
def test_basic(self):
a0 = np.array(1)
@@ -3244,7 +3244,7 @@ class TestMedian(object):
(1, 1, 7, 1))
-class TestAdd_newdoc_ufunc(object):
+class TestAdd_newdoc_ufunc:
def test_ufunc_arg(self):
assert_raises(TypeError, add_newdoc_ufunc, 2, "blah")
@@ -3254,7 +3254,7 @@ class TestAdd_newdoc_ufunc(object):
assert_raises(TypeError, add_newdoc_ufunc, np.add, 3)
-class TestAdd_newdoc(object):
+class TestAdd_newdoc:
@pytest.mark.skipif(sys.flags.optimize == 2, reason="Python running -OO")
@pytest.mark.xfail(IS_PYPY, reason="PyPy does not modify tp_doc")
@@ -3265,7 +3265,7 @@ class TestAdd_newdoc(object):
assert_(len(np.core.ufunc.identity.__doc__) > 300)
assert_(len(np.lib.index_tricks.mgrid.__doc__) > 300)
-class TestSortComplex(object):
+class TestSortComplex:
@pytest.mark.parametrize("type_in, type_out", [
('l', 'D'),
diff --git a/numpy/lib/tests/test_histograms.py b/numpy/lib/tests/test_histograms.py
index a78c3f4ec..c21103891 100644
--- a/numpy/lib/tests/test_histograms.py
+++ b/numpy/lib/tests/test_histograms.py
@@ -9,7 +9,7 @@ from numpy.testing import (
import pytest
-class TestHistogram(object):
+class TestHistogram:
def setup(self):
pass
@@ -422,7 +422,7 @@ class TestHistogram(object):
assert_array_equal(edges, e)
-class TestHistogramOptimBinNums(object):
+class TestHistogramOptimBinNums:
"""
Provide test coverage when using provided estimators for optimal number of
bins
@@ -610,7 +610,7 @@ class TestHistogramOptimBinNums(object):
estimator, weights=[1, 2, 3])
-class TestHistogramdd(object):
+class TestHistogramdd:
def test_simple(self):
x = np.array([[-.5, .5, 1.5], [-.5, 1.5, 2.5], [-.5, 2.5, .5],
diff --git a/numpy/lib/tests/test_index_tricks.py b/numpy/lib/tests/test_index_tricks.py
index bfc37ef9c..905165a99 100644
--- a/numpy/lib/tests/test_index_tricks.py
+++ b/numpy/lib/tests/test_index_tricks.py
@@ -12,7 +12,7 @@ from numpy.lib.index_tricks import (
)
-class TestRavelUnravelIndex(object):
+class TestRavelUnravelIndex:
def test_basic(self):
assert_equal(np.unravel_index(2, (2, 2)), (1, 0))
@@ -192,7 +192,7 @@ class TestRavelUnravelIndex(object):
with assert_raises(ValueError):
np.unravel_index([1], (2, 1, 0))
-class TestGrid(object):
+class TestGrid:
def test_basic(self):
a = mgrid[-1:1:10j]
b = mgrid[-1:1:0.1]
@@ -250,7 +250,7 @@ class TestGrid(object):
assert_equal(grid_small.size, expected[1])
-class TestConcatenator(object):
+class TestConcatenator:
def test_1d(self):
assert_array_equal(r_[1, 2, 3, 4, 5, 6], np.array([1, 2, 3, 4, 5, 6]))
b = np.ones(5)
@@ -288,14 +288,14 @@ class TestConcatenator(object):
assert_equal(r_[np.array(0), [1, 2, 3]], [0, 1, 2, 3])
-class TestNdenumerate(object):
+class TestNdenumerate:
def test_basic(self):
a = np.array([[1, 2], [3, 4]])
assert_equal(list(ndenumerate(a)),
[((0, 0), 1), ((0, 1), 2), ((1, 0), 3), ((1, 1), 4)])
-class TestIndexExpression(object):
+class TestIndexExpression:
def test_regression_1(self):
# ticket #1196
a = np.arange(2)
@@ -309,7 +309,7 @@ class TestIndexExpression(object):
assert_equal(a[:, :3, [1, 2]], a[s_[:, :3, [1, 2]]])
-class TestIx_(object):
+class TestIx_:
def test_regression_1(self):
# Test empty untyped inputs create outputs of indexing type, gh-5804
a, = np.ix_(range(0))
@@ -356,7 +356,7 @@ def test_c_():
assert_equal(a, [[1, 2, 3, 0, 0, 4, 5, 6]])
-class TestFillDiagonal(object):
+class TestFillDiagonal:
def test_basic(self):
a = np.zeros((3, 3), int)
fill_diagonal(a, 5)
@@ -455,7 +455,7 @@ def test_diag_indices():
)
-class TestDiagIndicesFrom(object):
+class TestDiagIndicesFrom:
def test_diag_indices_from(self):
x = np.random.random((4, 4))
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index 12ce65984..ba27eea6c 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -69,7 +69,7 @@ def strptime(s, fmt=None):
return datetime(*time.strptime(s, fmt)[:3])
-class RoundtripTest(object):
+class RoundtripTest:
def roundtrip(self, save_func, *args, **kwargs):
"""
save_func : callable
@@ -316,7 +316,7 @@ class TestSavezLoad(RoundtripTest):
assert_(fp.closed)
-class TestSaveTxt(object):
+class TestSaveTxt:
def test_array(self):
a = np.array([[1, 2], [3, 4]], float)
fmt = "%.18e"
@@ -582,7 +582,7 @@ class TestSaveTxt(object):
with tempdir() as tmpdir:
np.savez(os.path.join(tmpdir, 'test.npz'), test_data=test_data)
-class LoadTxtBase(object):
+class LoadTxtBase:
def check_compressed(self, fopen, suffixes):
# Test that we can load data from a compressed file
wanted = np.arange(6).reshape((2, 3))
@@ -824,7 +824,7 @@ class TestLoadTxt(LoadTxtBase):
assert_array_equal(x, a[:, 1])
# Testing with some crazy custom integer type
- class CrazyInt(object):
+ class CrazyInt:
def __index__(self):
return 1
@@ -1156,7 +1156,7 @@ class TestLoadTxt(LoadTxtBase):
a = np.array([[1, 2, 3, 5], [4, 5, 7, 8], [2, 1, 4, 5]], int)
assert_array_equal(x, a)
-class Testfromregex(object):
+class Testfromregex:
def test_record(self):
c = TextIO()
c.write('1.312 foo\n1.534 bar\n4.444 qux')
@@ -2347,7 +2347,7 @@ M 33 21.99
@pytest.mark.skipif(Path is None, reason="No pathlib.Path")
-class TestPathUsage(object):
+class TestPathUsage:
# Test that pathlib.Path can be used
def test_loadtxt(self):
with temppath(suffix='.txt') as path:
@@ -2480,7 +2480,7 @@ def test_gzip_load():
# These next two classes encode the minimal API needed to save()/load() arrays.
# The `test_ducktyping` ensures they work correctly
-class JustWriter(object):
+class JustWriter:
def __init__(self, base):
self.base = base
@@ -2490,7 +2490,7 @@ class JustWriter(object):
def flush(self):
return self.base.flush()
-class JustReader(object):
+class JustReader:
def __init__(self, base):
self.base = base
diff --git a/numpy/lib/tests/test_mixins.py b/numpy/lib/tests/test_mixins.py
index 948268e44..7c22dae94 100644
--- a/numpy/lib/tests/test_mixins.py
+++ b/numpy/lib/tests/test_mixins.py
@@ -96,7 +96,7 @@ _ALL_BINARY_OPERATORS = [
]
-class TestNDArrayOperatorsMixin(object):
+class TestNDArrayOperatorsMixin:
def test_array_like_add(self):
@@ -126,7 +126,7 @@ class TestNDArrayOperatorsMixin(object):
def test_opt_out(self):
- class OptOut(object):
+ class OptOut:
"""Object that opts out of __array_ufunc__."""
__array_ufunc__ = None
diff --git a/numpy/lib/tests/test_nanfunctions.py b/numpy/lib/tests/test_nanfunctions.py
index b0a7a04ee..db563e30c 100644
--- a/numpy/lib/tests/test_nanfunctions.py
+++ b/numpy/lib/tests/test_nanfunctions.py
@@ -35,7 +35,7 @@ _ndat_zeros = np.array([[0.6244, 0.0, 0.2692, 0.0116, 0.0, 0.1170],
[0.1610, 0.0, 0.0, 0.1859, 0.3146, 0.0]])
-class TestNanFunctions_MinMax(object):
+class TestNanFunctions_MinMax:
nanfuncs = [np.nanmin, np.nanmax]
stdfuncs = [np.min, np.max]
@@ -169,7 +169,7 @@ class TestNanFunctions_MinMax(object):
assert_(issubclass(w[0].category, RuntimeWarning))
-class TestNanFunctions_ArgminArgmax(object):
+class TestNanFunctions_ArgminArgmax:
nanfuncs = [np.nanargmin, np.nanargmax]
@@ -231,7 +231,7 @@ class TestNanFunctions_ArgminArgmax(object):
assert_(res.shape == ())
-class TestNanFunctions_IntTypes(object):
+class TestNanFunctions_IntTypes:
int_types = (np.int8, np.int16, np.int32, np.int64, np.uint8,
np.uint16, np.uint32, np.uint64)
@@ -306,7 +306,7 @@ class TestNanFunctions_IntTypes(object):
assert_equal(np.nanstd(mat, ddof=1), tgt)
-class SharedNanFunctionsTestsMixin(object):
+class SharedNanFunctionsTestsMixin:
def test_mutation(self):
# Check that passed array is not modified.
ndat = _ndat.copy()
@@ -588,7 +588,7 @@ class TestNanFunctions_MeanVarStd(SharedNanFunctionsTestsMixin):
assert_(len(w) == 0)
-class TestNanFunctions_Median(object):
+class TestNanFunctions_Median:
def test_mutation(self):
# Check that passed array is not modified.
@@ -752,7 +752,7 @@ class TestNanFunctions_Median(object):
([np.nan] * i) + [-inf] * j)
-class TestNanFunctions_Percentile(object):
+class TestNanFunctions_Percentile:
def test_mutation(self):
# Check that passed array is not modified.
@@ -891,7 +891,7 @@ class TestNanFunctions_Percentile(object):
assert_equal(np.nanpercentile(megamat, perc, axis=(1, 2)).shape, (2, 3, 6))
-class TestNanFunctions_Quantile(object):
+class TestNanFunctions_Quantile:
# most of this is already tested by TestPercentile
def test_regression(self):
diff --git a/numpy/lib/tests/test_polynomial.py b/numpy/lib/tests/test_polynomial.py
index 0d827eadf..cd0b90dc4 100644
--- a/numpy/lib/tests/test_polynomial.py
+++ b/numpy/lib/tests/test_polynomial.py
@@ -5,7 +5,7 @@ from numpy.testing import (
)
-class TestPolynomial(object):
+class TestPolynomial:
def test_poly1d_str_and_repr(self):
p = np.poly1d([1., 2, 3])
assert_equal(repr(p), 'poly1d([1., 2., 3.])')
diff --git a/numpy/lib/tests/test_recfunctions.py b/numpy/lib/tests/test_recfunctions.py
index cb4efa6c3..2f3c14df3 100644
--- a/numpy/lib/tests/test_recfunctions.py
+++ b/numpy/lib/tests/test_recfunctions.py
@@ -17,7 +17,7 @@ zip_descr = np.lib.recfunctions._zip_descr
zip_dtype = np.lib.recfunctions._zip_dtype
-class TestRecFunctions(object):
+class TestRecFunctions:
# Misc tests
def setup(self):
@@ -346,7 +346,7 @@ class TestRecFunctions(object):
assert_equal(b[()], 3)
-class TestRecursiveFillFields(object):
+class TestRecursiveFillFields:
# Test recursive_fill_fields.
def test_simple_flexible(self):
# Test recursive_fill_fields on flexible-array
@@ -369,7 +369,7 @@ class TestRecursiveFillFields(object):
assert_equal(test, control)
-class TestMergeArrays(object):
+class TestMergeArrays:
# Test merge_arrays
def setup(self):
@@ -502,7 +502,7 @@ class TestMergeArrays(object):
assert_equal(test, control)
-class TestAppendFields(object):
+class TestAppendFields:
# Test append_fields
def setup(self):
@@ -556,7 +556,7 @@ class TestAppendFields(object):
assert_equal(test, control)
-class TestStackArrays(object):
+class TestStackArrays:
# Test stack_arrays
def setup(self):
x = np.array([1, 2, ])
@@ -727,7 +727,7 @@ class TestStackArrays(object):
assert_equal(res.mask, expected.mask)
-class TestJoinBy(object):
+class TestJoinBy:
def setup(self):
self.a = np.array(list(zip(np.arange(10), np.arange(50, 60),
np.arange(100, 110))),
@@ -892,7 +892,7 @@ class TestJoinBy(object):
assert_equal(res.dtype, expected_dtype)
-class TestJoinBy2(object):
+class TestJoinBy2:
@classmethod
def setup(cls):
cls.a = np.array(list(zip(np.arange(10), np.arange(50, 60),
@@ -957,7 +957,7 @@ class TestJoinBy2(object):
assert_equal(test.dtype, control.dtype)
assert_equal(test, control)
-class TestAppendFieldsObj(object):
+class TestAppendFieldsObj:
"""
Test append_fields with arrays containing objects
"""
diff --git a/numpy/lib/tests/test_regression.py b/numpy/lib/tests/test_regression.py
index 6de89103a..019b7595e 100644
--- a/numpy/lib/tests/test_regression.py
+++ b/numpy/lib/tests/test_regression.py
@@ -9,7 +9,7 @@ from numpy.testing import (
from numpy.compat import unicode
-class TestRegression(object):
+class TestRegression:
def test_poly1d(self):
# Ticket #28
assert_equal(np.poly1d([1]) - np.poly1d([1, 0]),
diff --git a/numpy/lib/tests/test_shape_base.py b/numpy/lib/tests/test_shape_base.py
index 86e3744b8..fb7ba7874 100644
--- a/numpy/lib/tests/test_shape_base.py
+++ b/numpy/lib/tests/test_shape_base.py
@@ -27,7 +27,7 @@ def _add_keepdims(func):
return wrapped
-class TestTakeAlongAxis(object):
+class TestTakeAlongAxis:
def test_argequivalent(self):
""" Test it translates from arg<func> to <func> """
from numpy.random import rand
@@ -79,7 +79,7 @@ class TestTakeAlongAxis(object):
assert_equal(actual.shape, (3, 2, 5))
-class TestPutAlongAxis(object):
+class TestPutAlongAxis:
def test_replace_max(self):
a_base = np.array([[10, 30, 20], [60, 40, 50]])
@@ -104,7 +104,7 @@ class TestPutAlongAxis(object):
assert_equal(take_along_axis(a, ai, axis=1), 20)
-class TestApplyAlongAxis(object):
+class TestApplyAlongAxis:
def test_simple(self):
a = np.ones((20, 10), 'd')
assert_array_equal(
@@ -270,14 +270,14 @@ class TestApplyAlongAxis(object):
assert_equal(type(actual[i]), type(expected[i]))
-class TestApplyOverAxes(object):
+class TestApplyOverAxes:
def test_simple(self):
a = np.arange(24).reshape(2, 3, 4)
aoa_a = apply_over_axes(np.sum, a, [0, 2])
assert_array_equal(aoa_a, np.array([[[60], [92], [124]]]))
-class TestExpandDims(object):
+class TestExpandDims:
def test_functionality(self):
s = (2, 3, 4, 5)
a = np.empty(s)
@@ -317,7 +317,7 @@ class TestExpandDims(object):
assert_equal(expanded.mask.shape, (2, 1, 5))
-class TestArraySplit(object):
+class TestArraySplit:
def test_integer_0_split(self):
a = np.arange(10)
assert_raises(ValueError, array_split, a, 0)
@@ -451,7 +451,7 @@ class TestArraySplit(object):
compare_results(res, desired)
-class TestSplit(object):
+class TestSplit:
# The split function is essentially the same as array_split,
# except that it test if splitting will result in an
# equal split. Only test for this case.
@@ -467,7 +467,7 @@ class TestSplit(object):
assert_raises(ValueError, split, a, 3)
-class TestColumnStack(object):
+class TestColumnStack:
def test_non_iterable(self):
assert_raises(TypeError, column_stack, 1)
@@ -496,7 +496,7 @@ class TestColumnStack(object):
column_stack((np.arange(3) for _ in range(2)))
-class TestDstack(object):
+class TestDstack:
def test_non_iterable(self):
assert_raises(TypeError, dstack, 1)
@@ -535,7 +535,7 @@ class TestDstack(object):
# array_split has more comprehensive test of splitting.
# only do simple test on hsplit, vsplit, and dsplit
-class TestHsplit(object):
+class TestHsplit:
"""Only testing for integer splits.
"""
@@ -564,7 +564,7 @@ class TestHsplit(object):
compare_results(res, desired)
-class TestVsplit(object):
+class TestVsplit:
"""Only testing for integer splits.
"""
@@ -591,7 +591,7 @@ class TestVsplit(object):
compare_results(res, desired)
-class TestDsplit(object):
+class TestDsplit:
# Only testing for integer splits.
def test_non_iterable(self):
assert_raises(ValueError, dsplit, 1, 1)
@@ -624,7 +624,7 @@ class TestDsplit(object):
compare_results(res, desired)
-class TestSqueeze(object):
+class TestSqueeze:
def test_basic(self):
from numpy.random import rand
@@ -643,7 +643,7 @@ class TestSqueeze(object):
assert_equal(type(res), np.ndarray)
-class TestKron(object):
+class TestKron:
def test_return_type(self):
class myarray(np.ndarray):
__array_priority__ = 0.0
@@ -656,7 +656,7 @@ class TestKron(object):
assert_equal(type(kron(ma, a)), myarray)
-class TestTile(object):
+class TestTile:
def test_basic(self):
a = np.array([0, 1, 2])
b = [[1, 2], [3, 4]]
@@ -696,7 +696,7 @@ class TestTile(object):
assert_equal(large, klarge)
-class TestMayShareMemory(object):
+class TestMayShareMemory:
def test_basic(self):
d = np.ones((50, 60))
d2 = np.ones((30, 60, 6))
diff --git a/numpy/lib/tests/test_twodim_base.py b/numpy/lib/tests/test_twodim_base.py
index 1377794f6..cce683bfe 100644
--- a/numpy/lib/tests/test_twodim_base.py
+++ b/numpy/lib/tests/test_twodim_base.py
@@ -24,7 +24,7 @@ def get_mat(n):
return data
-class TestEye(object):
+class TestEye:
def test_basic(self):
assert_equal(eye(4),
array([[1, 0, 0, 0],
@@ -106,7 +106,7 @@ class TestEye(object):
assert mat_f.flags.f_contiguous
-class TestDiag(object):
+class TestDiag:
def test_vector(self):
vals = (100 * arange(5)).astype('l')
b = zeros((5, 5))
@@ -153,7 +153,7 @@ class TestDiag(object):
assert_raises(ValueError, diag, [[[1]]])
-class TestFliplr(object):
+class TestFliplr:
def test_basic(self):
assert_raises(ValueError, fliplr, ones(4))
a = get_mat(4)
@@ -166,7 +166,7 @@ class TestFliplr(object):
assert_equal(fliplr(a), b)
-class TestFlipud(object):
+class TestFlipud:
def test_basic(self):
a = get_mat(4)
b = a[::-1, :]
@@ -178,7 +178,7 @@ class TestFlipud(object):
assert_equal(flipud(a), b)
-class TestHistogram2d(object):
+class TestHistogram2d:
def test_simple(self):
x = array(
[0.41702200, 0.72032449, 1.1437481e-4, 0.302332573, 0.146755891])
@@ -296,7 +296,7 @@ class TestHistogram2d(object):
assert_(r, ((ShouldDispatch,), (xy, xy), dict(weights=s_d)))
-class TestTri(object):
+class TestTri:
def test_dtype(self):
out = array([[1, 0, 0],
[1, 1, 0],
@@ -434,7 +434,7 @@ def test_tril_indices():
[-10, -10, -10, -10, -10]]))
-class TestTriuIndices(object):
+class TestTriuIndices:
def test_triu_indices(self):
iu1 = triu_indices(4)
iu2 = triu_indices(4, k=2)
@@ -484,21 +484,21 @@ class TestTriuIndices(object):
[16, 17, 18, -1, -1]]))
-class TestTrilIndicesFrom(object):
+class TestTrilIndicesFrom:
def test_exceptions(self):
assert_raises(ValueError, tril_indices_from, np.ones((2,)))
assert_raises(ValueError, tril_indices_from, np.ones((2, 2, 2)))
# assert_raises(ValueError, tril_indices_from, np.ones((2, 3)))
-class TestTriuIndicesFrom(object):
+class TestTriuIndicesFrom:
def test_exceptions(self):
assert_raises(ValueError, triu_indices_from, np.ones((2,)))
assert_raises(ValueError, triu_indices_from, np.ones((2, 2, 2)))
# assert_raises(ValueError, triu_indices_from, np.ones((2, 3)))
-class TestVander(object):
+class TestVander:
def test_basic(self):
c = np.array([0, 1, -2, 3])
v = vander(c)
diff --git a/numpy/lib/tests/test_type_check.py b/numpy/lib/tests/test_type_check.py
index a8af147f1..47685550a 100644
--- a/numpy/lib/tests/test_type_check.py
+++ b/numpy/lib/tests/test_type_check.py
@@ -13,7 +13,7 @@ def assert_all(x):
assert_(np.all(x), x)
-class TestCommonType(object):
+class TestCommonType:
def test_basic(self):
ai32 = np.array([[1, 2], [3, 4]], dtype=np.int32)
af16 = np.array([[1, 2], [3, 4]], dtype=np.float16)
@@ -29,7 +29,7 @@ class TestCommonType(object):
assert_(common_type(acd) == np.cdouble)
-class TestMintypecode(object):
+class TestMintypecode:
def test_default_1(self):
for itype in '1bcsuwil':
@@ -79,7 +79,7 @@ class TestMintypecode(object):
assert_equal(mintypecode('idD'), 'D')
-class TestIsscalar(object):
+class TestIsscalar:
def test_basic(self):
assert_(np.isscalar(3))
@@ -90,7 +90,7 @@ class TestIsscalar(object):
assert_(np.isscalar(4.0))
-class TestReal(object):
+class TestReal:
def test_real(self):
y = np.random.rand(10,)
@@ -121,7 +121,7 @@ class TestReal(object):
assert_(not isinstance(out, np.ndarray))
-class TestImag(object):
+class TestImag:
def test_real(self):
y = np.random.rand(10,)
@@ -152,7 +152,7 @@ class TestImag(object):
assert_(not isinstance(out, np.ndarray))
-class TestIscomplex(object):
+class TestIscomplex:
def test_fail(self):
z = np.array([-1, 0, 1])
@@ -165,7 +165,7 @@ class TestIscomplex(object):
assert_array_equal(res, [1, 0, 0])
-class TestIsreal(object):
+class TestIsreal:
def test_pass(self):
z = np.array([-1, 0, 1j])
@@ -178,7 +178,7 @@ class TestIsreal(object):
assert_array_equal(res, [0, 1, 1])
-class TestIscomplexobj(object):
+class TestIscomplexobj:
def test_basic(self):
z = np.array([-1, 0, 1])
@@ -207,7 +207,7 @@ class TestIscomplexobj(object):
# (pandas.core.dtypes)
class PdComplex(np.complex128):
pass
- class PdDtype(object):
+ class PdDtype:
name = 'category'
names = None
type = PdComplex
@@ -231,7 +231,7 @@ class TestIscomplexobj(object):
assert_(iscomplexobj(a))
-class TestIsrealobj(object):
+class TestIsrealobj:
def test_basic(self):
z = np.array([-1, 0, 1])
assert_(isrealobj(z))
@@ -239,7 +239,7 @@ class TestIsrealobj(object):
assert_(not isrealobj(z))
-class TestIsnan(object):
+class TestIsnan:
def test_goodvalues(self):
z = np.array((-1., 0., 1.))
@@ -269,7 +269,7 @@ class TestIsnan(object):
assert_all(np.isnan(np.array(0+0j)/0.) == 1)
-class TestIsfinite(object):
+class TestIsfinite:
# Fixme, wrong place, isfinite now ufunc
def test_goodvalues(self):
@@ -300,7 +300,7 @@ class TestIsfinite(object):
assert_all(np.isfinite(np.array(1+1j)/0.) == 0)
-class TestIsinf(object):
+class TestIsinf:
# Fixme, wrong place, isinf now ufunc
def test_goodvalues(self):
@@ -329,7 +329,7 @@ class TestIsinf(object):
assert_all(np.isinf(np.array((0.,))/0.) == 0)
-class TestIsposinf(object):
+class TestIsposinf:
def test_generic(self):
with np.errstate(divide='ignore', invalid='ignore'):
@@ -339,7 +339,7 @@ class TestIsposinf(object):
assert_(vals[2] == 1)
-class TestIsneginf(object):
+class TestIsneginf:
def test_generic(self):
with np.errstate(divide='ignore', invalid='ignore'):
@@ -349,7 +349,7 @@ class TestIsneginf(object):
assert_(vals[2] == 0)
-class TestNanToNum(object):
+class TestNanToNum:
def test_generic(self):
with np.errstate(divide='ignore', invalid='ignore'):
@@ -454,7 +454,7 @@ class TestNanToNum(object):
assert_equal(type(vals), np.ndarray)
-class TestRealIfClose(object):
+class TestRealIfClose:
def test_basic(self):
a = np.random.rand(10)
@@ -467,7 +467,7 @@ class TestRealIfClose(object):
assert_all(isrealobj(b))
-class TestArrayConversion(object):
+class TestArrayConversion:
def test_asfarray(self):
a = asfarray(np.array([1, 2, 3]))
diff --git a/numpy/lib/tests/test_ufunclike.py b/numpy/lib/tests/test_ufunclike.py
index 527e093e6..c280b6969 100644
--- a/numpy/lib/tests/test_ufunclike.py
+++ b/numpy/lib/tests/test_ufunclike.py
@@ -6,7 +6,7 @@ from numpy.testing import (
)
-class TestUfunclike(object):
+class TestUfunclike:
def test_isposinf(self):
a = nx.array([nx.inf, -nx.inf, nx.nan, 0.0, 3.0, -3.0])
diff --git a/numpy/lib/tests/test_utils.py b/numpy/lib/tests/test_utils.py
index 20b394912..57c840342 100644
--- a/numpy/lib/tests/test_utils.py
+++ b/numpy/lib/tests/test_utils.py
@@ -100,7 +100,7 @@ def test_safe_eval_nameconstant():
utils.safe_eval('None')
-class TestByteBounds(object):
+class TestByteBounds:
def test_byte_bounds(self):
# pointer difference matches size * itemsize
diff --git a/numpy/lib/user_array.py b/numpy/lib/user_array.py
index 9172d4249..9c266fd6b 100644
--- a/numpy/lib/user_array.py
+++ b/numpy/lib/user_array.py
@@ -14,7 +14,7 @@ from numpy.core import (
from numpy.compat import long
-class container(object):
+class container:
"""
container(data, dtype=None, copy=True)
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py
index 8b335a9d8..d41a6e541 100644
--- a/numpy/lib/utils.py
+++ b/numpy/lib/utils.py
@@ -53,7 +53,7 @@ def _set_function_name(func, name):
return func
-class _Deprecate(object):
+class _Deprecate:
"""
Decorator class to deprecate old functions.