From c31cc36a8a814ed4844a2a553454185601914a5a Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 5 Jan 2020 00:53:30 -0500 Subject: 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. --- benchmarks/benchmarks/bench_function_base.py | 2 +- benchmarks/benchmarks/bench_overrides.py | 2 +- benchmarks/benchmarks/bench_ufunc.py | 2 +- benchmarks/benchmarks/common.py | 2 +- doc/TESTS.rst.txt | 4 +- doc/source/reference/random/multithreading.rst | 2 +- numpy/_globals.py | 2 +- numpy/_pytesttester.py | 2 +- numpy/compat/py3k.py | 2 +- numpy/core/_internal.py | 12 +- numpy/core/_ufunc_config.py | 4 +- numpy/core/arrayprint.py | 14 +- numpy/core/code_generators/genapi.py | 14 +- numpy/core/code_generators/generate_umath.py | 8 +- numpy/core/getlimits.py | 6 +- numpy/core/machar.py | 2 +- numpy/core/records.py | 2 +- numpy/core/setup.py | 2 +- numpy/core/tests/_locales.py | 2 +- numpy/core/tests/test_abc.py | 2 +- numpy/core/tests/test_arrayprint.py | 10 +- numpy/core/tests/test_datetime.py | 4 +- numpy/core/tests/test_defchararray.py | 16 +- numpy/core/tests/test_deprecations.py | 8 +- numpy/core/tests/test_dtype.py | 26 +-- numpy/core/tests/test_einsum.py | 4 +- numpy/core/tests/test_errstate.py | 2 +- numpy/core/tests/test_function_base.py | 8 +- numpy/core/tests/test_getlimits.py | 16 +- numpy/core/tests/test_half.py | 2 +- numpy/core/tests/test_indexerrors.py | 2 +- numpy/core/tests/test_indexing.py | 32 ++-- numpy/core/tests/test_item_selection.py | 2 +- numpy/core/tests/test_longdouble.py | 2 +- numpy/core/tests/test_machar.py | 2 +- numpy/core/tests/test_mem_overlap.py | 6 +- numpy/core/tests/test_memmap.py | 2 +- numpy/core/tests/test_multiarray.py | 180 ++++++++++----------- numpy/core/tests/test_nditer.py | 2 +- numpy/core/tests/test_numeric.py | 70 ++++---- numpy/core/tests/test_numerictypes.py | 26 +-- numpy/core/tests/test_overrides.py | 30 ++-- numpy/core/tests/test_records.py | 6 +- numpy/core/tests/test_regression.py | 12 +- numpy/core/tests/test_scalar_ctors.py | 4 +- numpy/core/tests/test_scalar_methods.py | 2 +- numpy/core/tests/test_scalarbuffer.py | 2 +- numpy/core/tests/test_scalarinherit.py | 6 +- numpy/core/tests/test_scalarmath.py | 30 ++-- numpy/core/tests/test_scalarprint.py | 2 +- numpy/core/tests/test_shape_base.py | 16 +- numpy/core/tests/test_ufunc.py | 12 +- numpy/core/tests/test_umath.py | 132 +++++++-------- numpy/core/tests/test_umath_accuracy.py | 2 +- numpy/core/tests/test_umath_complex.py | 12 +- numpy/core/tests/test_unicode.py | 8 +- numpy/distutils/command/config.py | 2 +- numpy/distutils/cpuinfo.py | 2 +- numpy/distutils/fcompiler/environment.py | 2 +- numpy/distutils/misc_util.py | 4 +- numpy/distutils/npy_pkg_config.py | 4 +- numpy/distutils/system_info.py | 2 +- numpy/distutils/tests/test_exec_command.py | 8 +- numpy/distutils/tests/test_fcompiler_gnu.py | 4 +- numpy/distutils/tests/test_fcompiler_intel.py | 4 +- numpy/distutils/tests/test_fcompiler_nagfor.py | 2 +- numpy/distutils/tests/test_misc_util.py | 8 +- numpy/distutils/tests/test_npy_pkg_config.py | 4 +- numpy/distutils/tests/test_system_info.py | 2 +- numpy/doc/glossary.py | 4 +- numpy/doc/subclassing.py | 2 +- numpy/f2py/auxfuncs.py | 2 +- numpy/f2py/tests/test_array_from_pyobj.py | 10 +- numpy/f2py/tests/test_callback.py | 2 +- numpy/f2py/tests/util.py | 2 +- numpy/fft/tests/test_helper.py | 8 +- numpy/fft/tests/test_pocketfft.py | 6 +- numpy/lib/_datasource.py | 4 +- numpy/lib/_iotools.py | 6 +- numpy/lib/arrayterator.py | 2 +- numpy/lib/function_base.py | 2 +- numpy/lib/index_tricks.py | 10 +- numpy/lib/mixins.py | 2 +- numpy/lib/npyio.py | 6 +- numpy/lib/polynomial.py | 2 +- numpy/lib/stride_tricks.py | 2 +- numpy/lib/tests/test__datasource.py | 12 +- numpy/lib/tests/test__iotools.py | 8 +- numpy/lib/tests/test_arraypad.py | 24 +-- numpy/lib/tests/test_arraysetops.py | 6 +- numpy/lib/tests/test_financial.py | 2 +- numpy/lib/tests/test_function_base.py | 90 +++++------ numpy/lib/tests/test_histograms.py | 6 +- numpy/lib/tests/test_index_tricks.py | 16 +- numpy/lib/tests/test_io.py | 16 +- numpy/lib/tests/test_mixins.py | 4 +- numpy/lib/tests/test_nanfunctions.py | 14 +- numpy/lib/tests/test_polynomial.py | 2 +- numpy/lib/tests/test_recfunctions.py | 16 +- numpy/lib/tests/test_regression.py | 2 +- numpy/lib/tests/test_shape_base.py | 32 ++-- numpy/lib/tests/test_twodim_base.py | 20 +-- numpy/lib/tests/test_type_check.py | 36 ++--- numpy/lib/tests/test_ufunclike.py | 2 +- numpy/lib/tests/test_utils.py | 2 +- numpy/lib/user_array.py | 2 +- numpy/lib/utils.py | 2 +- numpy/linalg/lapack_lite/clapack_scrub.py | 2 +- numpy/linalg/lapack_lite/fortran.py | 4 +- numpy/linalg/lapack_lite/make_lite.py | 4 +- numpy/linalg/tests/test_build.py | 4 +- numpy/linalg/tests/test_linalg.py | 26 +-- numpy/linalg/tests/test_regression.py | 2 +- numpy/ma/core.py | 20 +-- numpy/ma/extras.py | 2 +- numpy/ma/mrecords.py | 2 +- numpy/ma/tests/test_core.py | 36 ++--- numpy/ma/tests/test_deprecations.py | 4 +- numpy/ma/tests/test_extras.py | 28 ++-- numpy/ma/tests/test_mrecords.py | 6 +- numpy/ma/tests/test_old_ma.py | 6 +- numpy/ma/tests/test_regression.py | 2 +- numpy/ma/tests/test_subclassing.py | 4 +- numpy/ma/timer_comparison.py | 2 +- numpy/matrixlib/tests/test_defmatrix.py | 18 +-- numpy/matrixlib/tests/test_interaction.py | 2 +- numpy/matrixlib/tests/test_masked_matrix.py | 6 +- numpy/matrixlib/tests/test_multiarray.py | 2 +- numpy/matrixlib/tests/test_numeric.py | 2 +- numpy/matrixlib/tests/test_regression.py | 2 +- numpy/polynomial/polyutils.py | 2 +- numpy/polynomial/tests/test_chebyshev.py | 24 +-- numpy/polynomial/tests/test_classes.py | 4 +- numpy/polynomial/tests/test_hermite.py | 20 +-- numpy/polynomial/tests/test_hermite_e.py | 20 +-- numpy/polynomial/tests/test_laguerre.py | 20 +-- numpy/polynomial/tests/test_legendre.py | 20 +-- numpy/polynomial/tests/test_polynomial.py | 16 +- numpy/polynomial/tests/test_polyutils.py | 4 +- numpy/polynomial/tests/test_printing.py | 4 +- numpy/random/tests/test_direct.py | 4 +- numpy/random/tests/test_generator_mt19937.py | 20 +-- .../tests/test_generator_mt19937_regressions.py | 4 +- numpy/random/tests/test_random.py | 18 +-- numpy/random/tests/test_randomstate.py | 18 +-- numpy/random/tests/test_randomstate_regression.py | 4 +- numpy/random/tests/test_regression.py | 4 +- numpy/random/tests/test_smoke.py | 2 +- numpy/testing/_private/noseclasses.py | 2 +- numpy/testing/_private/nosetester.py | 2 +- numpy/testing/_private/parameterized.py | 4 +- numpy/testing/_private/utils.py | 2 +- numpy/testing/print_coercion_tables.py | 2 +- numpy/testing/tests/test_decorators.py | 2 +- numpy/testing/tests/test_utils.py | 28 ++-- numpy/tests/test_ctypeslib.py | 10 +- tools/allocation_tracking/alloc_hook.pyx | 2 +- tools/allocation_tracking/track_allocations.py | 2 +- tools/npy_tempita/__init__.py | 12 +- tools/npy_tempita/_looper.py | 6 +- tools/refguide_check.py | 2 +- 161 files changed, 845 insertions(+), 845 deletions(-) diff --git a/benchmarks/benchmarks/bench_function_base.py b/benchmarks/benchmarks/bench_function_base.py index 3b4647773..b1e592749 100644 --- a/benchmarks/benchmarks/bench_function_base.py +++ b/benchmarks/benchmarks/bench_function_base.py @@ -104,7 +104,7 @@ def memoize(f): return f -class SortGenerator(object): +class SortGenerator: # The size of the unsorted area in the "random unsorted area" # benchmarks AREA_SIZE = 100 diff --git a/benchmarks/benchmarks/bench_overrides.py b/benchmarks/benchmarks/bench_overrides.py index f03120efa..e44951785 100644 --- a/benchmarks/benchmarks/bench_overrides.py +++ b/benchmarks/benchmarks/bench_overrides.py @@ -33,7 +33,7 @@ def mock_concatenate(arrays, axis=0, out=None): pass -class DuckArray(object): +class DuckArray: def __array_function__(self, func, types, args, kwargs): pass diff --git a/benchmarks/benchmarks/bench_ufunc.py b/benchmarks/benchmarks/bench_ufunc.py index 73159bd97..9f45a7257 100644 --- a/benchmarks/benchmarks/bench_ufunc.py +++ b/benchmarks/benchmarks/bench_ufunc.py @@ -150,7 +150,7 @@ class Scalar(Benchmark): (self.y + self.z) -class ArgPack(object): +class ArgPack: __slots__ = ['args', 'kwargs'] def __init__(self, *args, **kwargs): self.args = args diff --git a/benchmarks/benchmarks/common.py b/benchmarks/benchmarks/common.py index c6037dea9..3fd81a164 100644 --- a/benchmarks/benchmarks/common.py +++ b/benchmarks/benchmarks/common.py @@ -110,5 +110,5 @@ def get_indexes_rand_(): return indexes_rand_ -class Benchmark(object): +class Benchmark: goal_time = 0.25 diff --git a/doc/TESTS.rst.txt b/doc/TESTS.rst.txt index 14cb28df8..9023c7100 100644 --- a/doc/TESTS.rst.txt +++ b/doc/TESTS.rst.txt @@ -119,7 +119,7 @@ that makes it hard to identify the test from the output of running the test suite with ``verbose=2`` (or similar verbosity setting). Use plain comments (``#``) if necessary. -Labeling tests +Labeling tests -------------- As an alternative to ``pytest.mark.