diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2020-01-05 00:53:30 -0500 |
---|---|---|
committer | Warren Weckesser <warren.weckesser@gmail.com> | 2020-01-05 00:53:30 -0500 |
commit | c31cc36a8a814ed4844a2a553454185601914a5a (patch) | |
tree | adb28a762dc0985eed669db75b564b3f5c3bfbcc /numpy/ma | |
parent | c1f1bc9ce8e4e2936e80d9bfafc3d8e03237a84b (diff) | |
download | numpy-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/ma')
-rw-r--r-- | numpy/ma/core.py | 20 | ||||
-rw-r--r-- | numpy/ma/extras.py | 2 | ||||
-rw-r--r-- | numpy/ma/mrecords.py | 2 | ||||
-rw-r--r-- | numpy/ma/tests/test_core.py | 36 | ||||
-rw-r--r-- | numpy/ma/tests/test_deprecations.py | 4 | ||||
-rw-r--r-- | numpy/ma/tests/test_extras.py | 28 | ||||
-rw-r--r-- | numpy/ma/tests/test_mrecords.py | 6 | ||||
-rw-r--r-- | numpy/ma/tests/test_old_ma.py | 6 | ||||
-rw-r--r-- | numpy/ma/tests/test_regression.py | 2 | ||||
-rw-r--r-- | numpy/ma/tests/test_subclassing.py | 4 | ||||
-rw-r--r-- | numpy/ma/timer_comparison.py | 2 |
11 files changed, 56 insertions, 56 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 3fa0d63b3..d51d8e6ec 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -798,7 +798,7 @@ ufunc_domain = {} ufunc_fills = {} -class _DomainCheckInterval(object): +class _DomainCheckInterval: """ Define a valid interval, so that : @@ -823,7 +823,7 @@ class _DomainCheckInterval(object): umath.less(x, self.a)) -class _DomainTan(object): +class _DomainTan: """ Define a valid interval for the `tan` function, so that: @@ -841,7 +841,7 @@ class _DomainTan(object): return umath.less(umath.absolute(umath.cos(x)), self.eps) -class _DomainSafeDivide(object): +class _DomainSafeDivide: """ Define a domain for safe division. @@ -862,7 +862,7 @@ class _DomainSafeDivide(object): return umath.absolute(a) * self.tolerance >= umath.absolute(b) -class _DomainGreater(object): +class _DomainGreater: """ DomainGreater(v)(x) is True where x <= v. @@ -878,7 +878,7 @@ class _DomainGreater(object): return umath.less_equal(x, self.critical_value) -class _DomainGreaterEqual(object): +class _DomainGreaterEqual: """ DomainGreaterEqual(v)(x) is True where x < v. @@ -894,7 +894,7 @@ class _DomainGreaterEqual(object): return umath.less(x, self.critical_value) -class _MaskedUFunc(object): +class _MaskedUFunc: def __init__(self, ufunc): self.f = ufunc self.__doc__ = ufunc.__doc__ @@ -2384,7 +2384,7 @@ def masked_invalid(a, copy=True): ############################################################################### -class _MaskedPrintOption(object): +class _MaskedPrintOption: """ Handle the string used to represent missing data in a masked array. @@ -2602,7 +2602,7 @@ def _arraymethod(funcname, onmask=True): return wrapped_method -class MaskedIterator(object): +class MaskedIterator: """ Flat iterator object to iterate over masked arrays. @@ -6644,7 +6644,7 @@ ptp.__doc__ = MaskedArray.ptp.__doc__ ############################################################################## -class _frommethod(object): +class _frommethod: """ Define functions from existing MaskedArray methods. @@ -7978,7 +7978,7 @@ def fromflex(fxarray): return masked_array(fxarray['_data'], mask=fxarray['_mask']) -class _convert2ma(object): +class _convert2ma: """ Convert functions from numpy to numpy.ma. diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py index 221e648c5..31648fb2e 100644 --- a/numpy/ma/extras.py +++ b/numpy/ma/extras.py @@ -212,7 +212,7 @@ def masked_all_like(arr): #####-------------------------------------------------------------------------- #---- --- Standard functions --- #####-------------------------------------------------------------------------- -class _fromnxfunction(object): +class _fromnxfunction: """ Defines a wrapper to adapt NumPy functions to masked arrays. diff --git a/numpy/ma/mrecords.py b/numpy/ma/mrecords.py index 83520d6b9..4ff7866ab 100644 --- a/numpy/ma/mrecords.py +++ b/numpy/ma/mrecords.py @@ -85,7 +85,7 @@ def _get_fieldmask(self): return fdmask -class MaskedRecords(MaskedArray, object): +class MaskedRecords(MaskedArray): """ Attributes diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index 31f973e68..458b78580 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -63,7 +63,7 @@ num_dts = [np.dtype(dt_) for dt_ in '?bhilqBHILQefdgFD'] num_ids = [dt_.char for dt_ in num_dts] -class TestMaskedArray(object): +class TestMaskedArray: # Base test class for MaskedArrays. def setup(self): @@ -944,7 +944,7 @@ class TestMaskedArray(object): assert_(mx2[0] == 0.) -class TestMaskedArrayArithmetic(object): +class TestMaskedArrayArithmetic: # Base test class for MaskedArrays. def setup(self): @@ -1713,7 +1713,7 @@ class TestMaskedArrayArithmetic(object): assert_equal(a.mask, [0, 0, 0, 0, 1]) -class TestMaskedArrayAttributes(object): +class TestMaskedArrayAttributes: def test_keepmask(self): # Tests the keep mask flag @@ -1889,7 +1889,7 @@ class TestMaskedArrayAttributes(object): assert_equal(m._mask, np.ma.nomask) -class TestFillingValues(object): +class TestFillingValues: def test_check_on_scalar(self): # Test _check_fill_value set to valid and invalid values @@ -2227,7 +2227,7 @@ class TestFillingValues(object): assert_equal(a["f1"].fill_value, default_fill_value("eggs")) -class TestUfuncs(object): +class TestUfuncs: # Test class for the application of ufuncs on MaskedArrays. def setup(self): @@ -2307,7 +2307,7 @@ class TestUfuncs(object): assert_raises(TypeError, operator.mul, a, "abc") assert_raises(TypeError, operator.truediv, a, "abc") - class MyClass(object): + class MyClass: __array_priority__ = a.__array_priority__ + 1 def __mul__(self, other): @@ -2321,7 +2321,7 @@ class TestUfuncs(object): assert_(a * me == "My rmul") # and that __array_priority__ is respected - class MyClass2(object): + class MyClass2: __array_priority__ = 100 def __mul__(self, other): @@ -2371,7 +2371,7 @@ class TestUfuncs(object): # also check that allclose uses ma ufuncs, to avoid warning allclose(m, 0.5) -class TestMaskedArrayInPlaceArithmetics(object): +class TestMaskedArrayInPlaceArithmetics: # Test MaskedArray Arithmetics def setup(self): @@ -2873,7 +2873,7 @@ class TestMaskedArrayInPlaceArithmetics(object): assert_equal(len(w), 0, "Failed on type=%s." % t) -class TestMaskedArrayMethods(object): +class TestMaskedArrayMethods: # Test class for miscellaneous MaskedArrays methods. def setup(self): # Base data definition. @@ -3580,7 +3580,7 @@ class TestMaskedArrayMethods(object): assert_equal(xd.data, x.diagonal().data) -class TestMaskedArrayMathMethods(object): +class TestMaskedArrayMathMethods: def setup(self): # Base data definition. @@ -3858,7 +3858,7 @@ class TestMaskedArrayMathMethods(object): assert_equal(a.max(1), [3, 6]) -class TestMaskedArrayMathMethodsComplex(object): +class TestMaskedArrayMathMethodsComplex: # Test class for miscellaneous MaskedArrays methods. def setup(self): # Base data definition. @@ -3911,7 +3911,7 @@ class TestMaskedArrayMathMethodsComplex(object): mX[:, k].compressed().std()) -class TestMaskedArrayFunctions(object): +class TestMaskedArrayFunctions: # Test class for miscellaneous functions. def setup(self): @@ -4550,7 +4550,7 @@ class TestMaskedArrayFunctions(object): assert_equal(test, masked_equal([-1, -1, -1, -1, -1], -1)) -class TestMaskedFields(object): +class TestMaskedFields: def setup(self): ilist = [1, 2, 3, 4, 5] @@ -4712,7 +4712,7 @@ class TestMaskedFields(object): assert_equal(len(rec), len(self.data['ddtype'])) -class TestMaskedObjectArray(object): +class TestMaskedObjectArray: def test_getitem(self): arr = np.ma.array([None, None]) @@ -4760,7 +4760,7 @@ class TestMaskedObjectArray(object): assert_(arr[0] is np.ma.masked) -class TestMaskedView(object): +class TestMaskedView: def setup(self): iterator = list(zip(np.arange(10), np.random.rand(10))) @@ -4838,7 +4838,7 @@ class TestMaskedView(object): assert_(not isinstance(test, MaskedArray)) -class TestOptionalArgs(object): +class TestOptionalArgs: def test_ndarrayfuncs(self): # test axis arg behaves the same as ndarray (including multiple axes) @@ -4925,7 +4925,7 @@ class TestOptionalArgs(object): assert_raises(np.AxisError, count, np.ma.array(1), axis=1) -class TestMaskedConstant(object): +class TestMaskedConstant: def _do_add_test(self, add): # sanity check assert_(add(np.ma.masked, 1) is np.ma.masked) @@ -5042,7 +5042,7 @@ class TestMaskedConstant(object): assert_raises(AttributeError, setattr, np.ma.masked, 'dtype', np.int64) -class TestMaskedWhereAliases(object): +class TestMaskedWhereAliases: # TODO: Test masked_object, masked_equal, ... diff --git a/numpy/ma/tests/test_deprecations.py b/numpy/ma/tests/test_deprecations.py index 7f44a2176..14f697375 100644 --- a/numpy/ma/tests/test_deprecations.py +++ b/numpy/ma/tests/test_deprecations.py @@ -6,7 +6,7 @@ from numpy.testing import assert_warns from numpy.ma.testutils import assert_equal from numpy.ma.core import MaskedArrayFutureWarning -class TestArgsort(object): +class TestArgsort: """ gh-8701 """ def _test_base(self, argsort, cls): arr_0d = np.array(1).view(cls) @@ -35,7 +35,7 @@ class TestArgsort(object): return self._test_base(np.ma.MaskedArray.argsort, np.ma.MaskedArray) -class TestMinimumMaximum(object): +class TestMinimumMaximum: def test_minimum(self): assert_warns(DeprecationWarning, np.ma.minimum, np.ma.array([1, 2])) diff --git a/numpy/ma/tests/test_extras.py b/numpy/ma/tests/test_extras.py index c36bcbbbb..1c8610625 100644 --- a/numpy/ma/tests/test_extras.py +++ b/numpy/ma/tests/test_extras.py @@ -32,7 +32,7 @@ from numpy.ma.extras import ( ) -class TestGeneric(object): +class TestGeneric: # def test_masked_all(self): # Tests masked_all @@ -140,7 +140,7 @@ class TestGeneric(object): assert_equal(test, []) -class TestAverage(object): +class TestAverage: # Several tests of average. Why so many ? Good point... def test_testAverage1(self): # Test of average. @@ -271,7 +271,7 @@ class TestAverage(object): assert_almost_equal(wav1.imag, expected1.imag) -class TestConcatenator(object): +class TestConcatenator: # Tests for mr_, the equivalent of r_ for masked arrays. def test_1d(self): @@ -315,7 +315,7 @@ class TestConcatenator(object): assert_equal(actual.data[:2], [1, 2]) -class TestNotMasked(object): +class TestNotMasked: # Tests notmasked_edges and notmasked_contiguous. def test_edges(self): @@ -385,7 +385,7 @@ class TestNotMasked(object): ]) -class TestCompressFunctions(object): +class TestCompressFunctions: def test_compress_nd(self): # Tests compress_nd @@ -650,7 +650,7 @@ class TestCompressFunctions(object): assert_equal(a, res) -class TestApplyAlongAxis(object): +class TestApplyAlongAxis: # Tests 2D functions def test_3d(self): a = arange(12.).reshape(2, 2, 3) @@ -672,7 +672,7 @@ class TestApplyAlongAxis(object): assert_equal(xa, [[2, 5], [8, 11]]) -class TestApplyOverAxes(object): +class TestApplyOverAxes: # Tests apply_over_axes def test_basic(self): a = arange(24).reshape(2, 3, 4) @@ -685,7 +685,7 @@ class TestApplyOverAxes(object): assert_equal(test, ctrl) -class TestMedian(object): +class TestMedian: def test_pytype(self): r = np.ma.median([[np.inf, np.inf], [np.inf, np.inf]], axis=-1) assert_equal(r, np.inf) @@ -1064,7 +1064,7 @@ class TestMedian(object): assert_(type(np.ma.median(o.astype(object))), float) -class TestCov(object): +class TestCov: def setup(self): self.data = array(np.random.rand(12)) @@ -1131,7 +1131,7 @@ class TestCov(object): x.shape[0] / frac)) -class TestCorrcoef(object): +class TestCorrcoef: def setup(self): self.data = array(np.random.rand(12)) @@ -1238,7 +1238,7 @@ class TestCorrcoef(object): control[:-1, :-1]) -class TestPolynomial(object): +class TestPolynomial: # def test_polyfit(self): # Tests polyfit @@ -1296,7 +1296,7 @@ class TestPolynomial(object): assert_almost_equal(a, a_) -class TestArraySetOps(object): +class TestArraySetOps: def test_unique_onlist(self): # Test unique on list @@ -1528,7 +1528,7 @@ class TestArraySetOps(object): assert_array_equal(setdiff1d(a, b), np.array(['c'])) -class TestShapeBase(object): +class TestShapeBase: def test_atleast_2d(self): # Test atleast_2d @@ -1584,7 +1584,7 @@ class TestShapeBase(object): assert_equal(b.mask.shape, b.data.shape) -class TestStack(object): +class TestStack: def test_stack_1d(self): a = masked_array([0, 1, 2], mask=[0, 1, 0]) diff --git a/numpy/ma/tests/test_mrecords.py b/numpy/ma/tests/test_mrecords.py index 14d39d949..c2f859273 100644 --- a/numpy/ma/tests/test_mrecords.py +++ b/numpy/ma/tests/test_mrecords.py @@ -24,7 +24,7 @@ from numpy.ma.testutils import ( from numpy.compat import pickle -class TestMRecords(object): +class TestMRecords: ilist = [1, 2, 3, 4, 5] flist = [1.1, 2.2, 3.3, 4.4, 5.5] @@ -346,7 +346,7 @@ class TestMRecords(object): dtype=mult.dtype)) -class TestView(object): +class TestView: def setup(self): (a, b) = (np.arange(10), np.random.rand(10)) @@ -384,7 +384,7 @@ class TestView(object): ############################################################################## -class TestMRecordsImport(object): +class TestMRecordsImport: _a = ma.array([1, 2, 3], mask=[0, 0, 1], dtype=int) _b = ma.array([1.1, 2.2, 3.3], mask=[0, 0, 1], dtype=float) diff --git a/numpy/ma/tests/test_old_ma.py b/numpy/ma/tests/test_old_ma.py index 5d5046c09..96c7e3609 100644 --- a/numpy/ma/tests/test_old_ma.py +++ b/numpy/ma/tests/test_old_ma.py @@ -31,7 +31,7 @@ def eq(v, w, msg=''): return result -class TestMa(object): +class TestMa: def setup(self): x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.]) @@ -698,7 +698,7 @@ class TestMa(object): assert_equal(b[1].shape, ()) -class TestUfuncs(object): +class TestUfuncs: def setup(self): self.d = (array([1.0, 0, -1, pi / 2] * 2, mask=[0, 1] + [0] * 6), array([1.0, 0, -1, pi / 2] * 2, mask=[1, 0] + [0] * 6),) @@ -763,7 +763,7 @@ class TestUfuncs(object): assert_(eq(nonzero(x), [0])) -class TestArrayMethods(object): +class TestArrayMethods: def setup(self): x = np.array([8.375, 7.545, 8.828, 8.5, 1.757, 5.928, diff --git a/numpy/ma/tests/test_regression.py b/numpy/ma/tests/test_regression.py index 32e8e30c1..9f3368489 100644 --- a/numpy/ma/tests/test_regression.py +++ b/numpy/ma/tests/test_regression.py @@ -4,7 +4,7 @@ from numpy.testing import ( ) -class TestRegression(object): +class TestRegression: def test_masked_array_create(self): # Ticket #17 x = np.ma.masked_array([0, 1, 2, 3, 0, 4, 5, 6], diff --git a/numpy/ma/tests/test_subclassing.py b/numpy/ma/tests/test_subclassing.py index 781079371..02aeebd17 100644 --- a/numpy/ma/tests/test_subclassing.py +++ b/numpy/ma/tests/test_subclassing.py @@ -78,7 +78,7 @@ msubarray = MSubArray # and overrides __array_wrap__, updating the info dict, to check that this # doesn't get destroyed by MaskedArray._update_from. But this one also needs # its own iterator... -class CSAIterator(object): +class CSAIterator: """ Flat iterator object that uses its own setter/getter (works around ndarray.flat not propagating subclass setters/getters @@ -152,7 +152,7 @@ class ComplicatedSubArray(SubArray): return obj -class TestSubclassing(object): +class TestSubclassing: # Test suite for masked subclasses of ndarray. def setup(self): diff --git a/numpy/ma/timer_comparison.py b/numpy/ma/timer_comparison.py index fc63c18b5..83bd7852e 100644 --- a/numpy/ma/timer_comparison.py +++ b/numpy/ma/timer_comparison.py @@ -13,7 +13,7 @@ np.seterr(all='ignore') pi = np.pi -class ModuleTester(object): +class ModuleTester: def __init__(self, module): self.module = module self.allequal = module.allequal |