diff --git a/doc/source/devel/biaps/biap_0002.rst b/doc/source/devel/biaps/biap_0002.rst index 1dccfce746..89ba4e913a 100644 --- a/doc/source/devel/biaps/biap_0002.rst +++ b/doc/source/devel/biaps/biap_0002.rst @@ -104,8 +104,8 @@ sliced array, as in: .. code:: python - class SomeImage(object): - class Slicer(object): + class SomeImage: + class Slicer: def __init__(self, parent): self.parent = parent def __getitem__(self, slicedef): diff --git a/doc/tools/apigen.py b/doc/tools/apigen.py index 52966300e2..cabbd319c5 100644 --- a/doc/tools/apigen.py +++ b/doc/tools/apigen.py @@ -28,7 +28,7 @@ DEBUG = True -class ApiDocWriter(object): +class ApiDocWriter: """ Class for automatic detection and parsing of API docs to Sphinx-parsable reST format""" @@ -118,7 +118,7 @@ def _get_object_name(self, line): >>> docwriter = ApiDocWriter('sphinx') >>> docwriter._get_object_name(" def func(): ") 'func' - >>> docwriter._get_object_name(" class Klass(object): ") + >>> docwriter._get_object_name(" class Klass: ") 'Klass' >>> docwriter._get_object_name(" class Klass: ") 'Klass' diff --git a/nibabel/arraywriters.py b/nibabel/arraywriters.py index 8523d9fedd..cdbec32fc6 100644 --- a/nibabel/arraywriters.py +++ b/nibabel/arraywriters.py @@ -45,7 +45,7 @@ class ScalingError(WriterError): pass -class ArrayWriter(object): +class ArrayWriter: def __init__(self, array, out_dtype=None, **kwargs): r""" Initialize array writer diff --git a/nibabel/batteryrunners.py b/nibabel/batteryrunners.py index 882c1814ef..a860ba3778 100644 --- a/nibabel/batteryrunners.py +++ b/nibabel/batteryrunners.py @@ -108,7 +108,7 @@ def chk_pixdims(hdr, fix=True): """ -class BatteryRunner(object): +class BatteryRunner: """ Class to run set of checks """ def __init__(self, checks): @@ -174,7 +174,7 @@ def __len__(self): return len(self._checks) -class Report(object): +class Report: def __init__(self, error=Exception, diff --git a/nibabel/cmdline/dicomfs.py b/nibabel/cmdline/dicomfs.py index d4c9d8ff1f..9b1b735cca 100644 --- a/nibabel/cmdline/dicomfs.py +++ b/nibabel/cmdline/dicomfs.py @@ -18,7 +18,7 @@ import logging -class dummy_fuse(object): +class dummy_fuse: """Dummy fuse "module" so that nose does not blow during doctests""" Fuse = object diff --git a/nibabel/data.py b/nibabel/data.py index 438cd2aa58..3845912936 100644 --- a/nibabel/data.py +++ b/nibabel/data.py @@ -31,7 +31,7 @@ class BomberError(DataError, AttributeError): pass -class Datasource(object): +class Datasource: """ Simple class to add base path to relative path """ def __init__(self, base_path): @@ -302,7 +302,7 @@ def make_datasource(pkg_def, **kwargs): return VersionedDatasource(pth) -class Bomber(object): +class Bomber: """ Class to raise an informative error when used """ def __init__(self, name, msg): diff --git a/nibabel/deprecated.py b/nibabel/deprecated.py index 2dd1f11db3..576d18b5ce 100644 --- a/nibabel/deprecated.py +++ b/nibabel/deprecated.py @@ -7,7 +7,7 @@ from .pkg_info import cmp_pkg_version -class ModuleProxy(object): +class ModuleProxy: """ Proxy for module that may not yet have been imported Parameters @@ -39,12 +39,12 @@ def __repr__(self): return f"" -class FutureWarningMixin(object): +class FutureWarningMixin: """ Insert FutureWarning for object creation Examples -------- - >>> class C(object): pass + >>> class C: pass >>> class D(FutureWarningMixin, C): ... warn_message = "Please, don't use this class" diff --git a/nibabel/deprecator.py b/nibabel/deprecator.py index 7dc32bbe58..3ff9516aec 100644 --- a/nibabel/deprecator.py +++ b/nibabel/deprecator.py @@ -83,7 +83,7 @@ def _add_dep_doc(old_doc, dep_doc, setup='', cleanup=''): old_lines[next_line:] + cleanup_lines + ['']) -class Deprecator(object): +class Deprecator: """ Class to make decorator marking function or method as deprecated The decorated function / method will: diff --git a/nibabel/dft.py b/nibabel/dft.py index f87002379e..3de1b31254 100644 --- a/nibabel/dft.py +++ b/nibabel/dft.py @@ -58,7 +58,7 @@ def __str__(self): return fmt % (self.i + 1, self.si.instance_number) -class _Study(object): +class _Study: def __init__(self, d): self.uid = d['uid'] @@ -91,7 +91,7 @@ def patient_name_or_uid(self): return self.patient_name -class _Series(object): +class _Series: def __init__(self, d): self.uid = d['uid'] @@ -219,7 +219,7 @@ def nifti_size(self): return 352 + 2 * len(self.storage_instances) * self.columns * self.rows -class _StorageInstance(object): +class _StorageInstance: def __init__(self, d): self.uid = d['uid'] diff --git a/nibabel/ecat.py b/nibabel/ecat.py index f87778fc6c..f206e482de 100644 --- a/nibabel/ecat.py +++ b/nibabel/ecat.py @@ -511,7 +511,7 @@ def read_subheaders(fileobj, mlist, endianness): return subheaders -class EcatSubHeader(object): +class EcatSubHeader: _subhdrdtype = subhdr_dtype _data_type_codes = data_type_codes @@ -660,7 +660,7 @@ def data_from_fileobj(self, frame=0, orientation=None): return data -class EcatImageArrayProxy(object): +class EcatImageArrayProxy: """ Ecat implementation of array proxy protocol The array proxy allows us to freeze the passed fileobj and diff --git a/nibabel/filebasedimages.py b/nibabel/filebasedimages.py index 4a194576b3..180fe7c6a7 100644 --- a/nibabel/filebasedimages.py +++ b/nibabel/filebasedimages.py @@ -22,7 +22,7 @@ class ImageFileError(Exception): pass -class FileBasedHeader(object): +class FileBasedHeader: """ Template class to implement header protocol """ @classmethod @@ -60,7 +60,7 @@ def copy(self): return deepcopy(self) -class FileBasedImage(object): +class FileBasedImage: """ Abstract image class with interface for loading/saving images from disk. diff --git a/nibabel/fileholders.py b/nibabel/fileholders.py index c996725991..f7dc9629fd 100644 --- a/nibabel/fileholders.py +++ b/nibabel/fileholders.py @@ -17,7 +17,7 @@ class FileHolderError(Exception): pass -class FileHolder(object): +class FileHolder: """ class to contain filename, fileobj and file position """ diff --git a/nibabel/fileslice.py b/nibabel/fileslice.py index d0bd3ca721..cc850132b8 100644 --- a/nibabel/fileslice.py +++ b/nibabel/fileslice.py @@ -16,7 +16,7 @@ SKIP_THRESH = 2 ** 8 -class _NullLock(object): +class _NullLock: """Can be used as no-function dummy object in place of ``threading.lock``. The ``_NullLock`` is an object which can be used in place of a diff --git a/nibabel/imageglobals.py b/nibabel/imageglobals.py index 91ebaf38ea..4cdeb7b1a3 100644 --- a/nibabel/imageglobals.py +++ b/nibabel/imageglobals.py @@ -31,7 +31,7 @@ logger.addHandler(logging.StreamHandler()) -class ErrorLevel(object): +class ErrorLevel: """ Context manager to set log error level """ @@ -49,7 +49,7 @@ def __exit__(self, exc, value, tb): return False -class LoggingOutputSuppressor(object): +class LoggingOutputSuppressor: """Context manager to prevent global logger from printing""" def __enter__(self): diff --git a/nibabel/minc1.py b/nibabel/minc1.py index c172f40a8e..c0ae95bd7b 100644 --- a/nibabel/minc1.py +++ b/nibabel/minc1.py @@ -39,7 +39,7 @@ class MincError(Exception): """ Error when reading MINC files """ -class Minc1File(object): +class Minc1File: """ Class to wrap MINC1 format opened netcdf object Although it has some of the same methods as a ``Header``, we use @@ -235,7 +235,7 @@ def get_scaled_data(self, sliceobj=()): return self._normalize(data, sliceobj) -class MincImageArrayProxy(object): +class MincImageArrayProxy: """ MINC implementation of array proxy protocol The array proxy allows us to freeze the passed fileobj and diff --git a/nibabel/minc2.py b/nibabel/minc2.py index a71ec7c693..3dce425609 100644 --- a/nibabel/minc2.py +++ b/nibabel/minc2.py @@ -30,7 +30,7 @@ from .minc1 import Minc1File, MincHeader, Minc1Image, MincError -class Hdf5Bunch(object): +class Hdf5Bunch: """ Make object for accessing attributes of variable """ diff --git a/nibabel/nicom/dicomwrappers.py b/nibabel/nicom/dicomwrappers.py index 38e501be5c..85e1655bc7 100755 --- a/nibabel/nicom/dicomwrappers.py +++ b/nibabel/nicom/dicomwrappers.py @@ -96,7 +96,7 @@ def wrapper_from_data(dcm_data): return SiemensWrapper(dcm_data, csa) -class Wrapper(object): +class Wrapper: """ Class to wrap general DICOM files Methods: diff --git a/nibabel/nicom/structreader.py b/nibabel/nicom/structreader.py index 644f50d345..eb714804f1 100644 --- a/nibabel/nicom/structreader.py +++ b/nibabel/nicom/structreader.py @@ -5,7 +5,7 @@ _ENDIAN_CODES = '@=<>!' -class Unpacker(object): +class Unpacker: """ Class to unpack values from buffer object The buffer object is usually a string. Caches compiled :mod:`struct` diff --git a/nibabel/nicom/tests/test_dicomwrappers.py b/nibabel/nicom/tests/test_dicomwrappers.py index 11b5b482b9..fcb3cc1703 100755 --- a/nibabel/nicom/tests/test_dicomwrappers.py +++ b/nibabel/nicom/tests/test_dicomwrappers.py @@ -124,7 +124,7 @@ class FakeData(dict): assert dw.get('some_key') is None # Check get defers to dcm_data get - class FakeData2(object): + class FakeData2: def get(self, key, default): return 1 @@ -268,7 +268,7 @@ def test_vol_matching(): # Just to check the interface, make a pretend signature-providing # object. - class C(object): + class C: series_signature = {} assert dw_empty.is_same_series(C()) @@ -386,7 +386,7 @@ def fake_frames(seq_name, field_name, value_seq): each element in list is obj.[0]. = value_seq[n] for n in range(N) """ - class Fake(object): + class Fake: pass frames = [] for value in value_seq: @@ -410,16 +410,16 @@ def fake_shape_dependents(div_seq, sid_seq=None, sid_dim=None): sid_dim : int the index of the column in 'div_seq' to use as 'sid_seq' """ - class DimIdxSeqElem(object): + class DimIdxSeqElem: def __init__(self, dip=(0, 0), fgp=None): self.DimensionIndexPointer = dip if fgp is not None: self.FunctionalGroupPointer = fgp - class FrmContSeqElem(object): + class FrmContSeqElem: def __init__(self, div, sid): self.DimensionIndexValues = div self.StackID = sid - class PerFrmFuncGrpSeqElem(object): + class PerFrmFuncGrpSeqElem: def __init__(self, div, sid): self.FrameContentSequence = [FrmContSeqElem(div, sid)] # if no StackID values passed in then use the values at index 'sid_dim' in diff --git a/nibabel/nifti1.py b/nibabel/nifti1.py index 5be146a89c..d434e50c32 100644 --- a/nibabel/nifti1.py +++ b/nibabel/nifti1.py @@ -253,7 +253,7 @@ ), fields=('code', 'label', 'parameters', 'niistring')) -class Nifti1Extension(object): +class Nifti1Extension: """Baseclass for NIfTI1 header extensions. This class is sufficient to handle very simple text-based extensions, such diff --git a/nibabel/onetime.py b/nibabel/onetime.py index 3ca31bea50..6b8debc51b 100644 --- a/nibabel/onetime.py +++ b/nibabel/onetime.py @@ -27,7 +27,7 @@ # ----------------------------------------------------------------------------- -class ResetMixin(object): +class ResetMixin: """A Mixin class to add a .reset() method to users of OneTimeProperty. By default, auto attributes once computed, become static. If they happen @@ -109,7 +109,7 @@ def reset(self): delattr(self, mname) -class OneTimeProperty(object): +class OneTimeProperty: """A descriptor to make special properties that become normal attributes. This is meant to be used mostly by the auto_attr decorator in this module. @@ -157,7 +157,7 @@ def auto_attr(func): Examples -------- - >>> class MagicProp(object): + >>> class MagicProp: ... @auto_attr ... def a(self): ... return 99 diff --git a/nibabel/openers.py b/nibabel/openers.py index b593ef82e7..b50da10c59 100644 --- a/nibabel/openers.py +++ b/nibabel/openers.py @@ -80,7 +80,7 @@ def _zstd_open(filename, mode="r", *, level_or_option=None, zstd_dict=None): level_or_option=level_or_option, zstd_dict=zstd_dict) -class Opener(object): +class Opener: r""" Class to accept, maybe open, and context-manage file-likes / filenames Provides context manager to close files that the constructor opened for diff --git a/nibabel/parrec.py b/nibabel/parrec.py index 046e1ec704..c2d7160806 100644 --- a/nibabel/parrec.py +++ b/nibabel/parrec.py @@ -579,7 +579,7 @@ def exts2pars(exts_source): return headers -class PARRECArrayProxy(object): +class PARRECArrayProxy: def __init__(self, file_like, header, *, mmap=True, scaling='dv'): """ Initialize PARREC array proxy diff --git a/nibabel/spatialimages.py b/nibabel/spatialimages.py index 9a2dc76db7..d2e69a0fc5 100644 --- a/nibabel/spatialimages.py +++ b/nibabel/spatialimages.py @@ -322,7 +322,7 @@ class ImageDataError(Exception): pass -class SpatialFirstSlicer(object): +class SpatialFirstSlicer: """ Slicing interface that returns a new image with an updated affine Checks that an image's first three axes are spatial diff --git a/nibabel/streamlines/array_sequence.py b/nibabel/streamlines/array_sequence.py index 2cefc84e47..5d40937b1c 100644 --- a/nibabel/streamlines/array_sequence.py +++ b/nibabel/streamlines/array_sequence.py @@ -24,7 +24,7 @@ def is_ndarray_of_int_or_bool(obj): np.issubdtype(obj.dtype, np.bool_))) -class _BuildCache(object): +class _BuildCache: def __init__(self, arr_seq, common_shape, dtype): self.offsets = list(arr_seq._offsets) self.lengths = list(arr_seq._lengths) @@ -88,7 +88,7 @@ def fn_binary_op(self, value): @_define_operators -class ArraySequence(object): +class ArraySequence: """ Sequence of ndarrays having variable first dimension sizes. This is a container that can store multiple ndarrays where each ndarray diff --git a/nibabel/streamlines/header.py b/nibabel/streamlines/header.py index 9ee7854d30..523035f3ee 100644 --- a/nibabel/streamlines/header.py +++ b/nibabel/streamlines/header.py @@ -2,7 +2,7 @@ """ -class Field(object): +class Field: """ Header fields common to multiple streamline file formats. In IPython, use `nibabel.streamlines.Field??` to list them. diff --git a/nibabel/streamlines/tractogram.py b/nibabel/streamlines/tractogram.py index 3d48b4b687..5b67af1ab3 100644 --- a/nibabel/streamlines/tractogram.py +++ b/nibabel/streamlines/tractogram.py @@ -220,7 +220,7 @@ def __len__(self): return len(self.store) -class TractogramItem(object): +class TractogramItem: """ Class containing information about one streamline. :class:`TractogramItem` objects have three public attributes: `streamline`, @@ -253,7 +253,7 @@ def __len__(self): return len(self.streamline) -class Tractogram(object): +class Tractogram: """ Container for streamlines and their data information. Streamlines of a tractogram can be in any coordinate system of your diff --git a/nibabel/tests/scriptrunner.py b/nibabel/tests/scriptrunner.py index bc7e9977f0..1bffd01929 100644 --- a/nibabel/tests/scriptrunner.py +++ b/nibabel/tests/scriptrunner.py @@ -46,7 +46,7 @@ def local_module_dir(module_name): return None -class ScriptRunner(object): +class ScriptRunner: """ Class to run scripts and return output Finds local scripts and local modules if running in the development diff --git a/nibabel/tests/test_analyze.py b/nibabel/tests/test_analyze.py index bbcdfbeefc..e68dcf0685 100644 --- a/nibabel/tests/test_analyze.py +++ b/nibabel/tests/test_analyze.py @@ -523,7 +523,7 @@ def test_from_header(self): assert hdr == copy assert hdr is not copy - class C(object): + class C: def get_data_dtype(self): return np.dtype('i2') @@ -619,12 +619,12 @@ def test_from_analyze_map(self): klass = self.header_class # Header needs to implement data_dtype, data_shape, zooms - class H1(object): + class H1: pass with pytest.raises(AttributeError): klass.from_header(H1()) - class H2(object): + class H2: def get_data_dtype(self): return np.dtype('u1') diff --git a/nibabel/tests/test_api_validators.py b/nibabel/tests/test_api_validators.py index 76043348c9..668f4351db 100644 --- a/nibabel/tests/test_api_validators.py +++ b/nibabel/tests/test_api_validators.py @@ -61,7 +61,7 @@ def obj_params(self): against ``obj``. See the :meth:`validate_something` method for an example. """ - class C(object): + class C: def __init__(self, var): self.var = var diff --git a/nibabel/tests/test_arrayproxy.py b/nibabel/tests/test_arrayproxy.py index ed89105aa0..6857fdb1f7 100644 --- a/nibabel/tests/test_arrayproxy.py +++ b/nibabel/tests/test_arrayproxy.py @@ -36,7 +36,7 @@ from .test_openers import patch_indexed_gzip -class FunkyHeader(object): +class FunkyHeader: def __init__(self, shape): self.shape = shape @@ -258,7 +258,7 @@ def test_is_proxy(): assert not is_proxy(hdr) assert not is_proxy(np.zeros((2, 3, 4))) - class NP(object): + class NP: is_proxy = False assert not is_proxy(NP()) @@ -280,7 +280,7 @@ def test_reshape_dataobj(): np.reshape(arr, (2, 3, 4))) assert arr.shape == shape - class ArrGiver(object): + class ArrGiver: def __array__(self): return arr diff --git a/nibabel/tests/test_brikhead.py b/nibabel/tests/test_brikhead.py index 45e149b93b..9f3bfdd93c 100644 --- a/nibabel/tests/test_brikhead.py +++ b/nibabel/tests/test_brikhead.py @@ -71,7 +71,7 @@ ) ] -class TestAFNIHeader(object): +class TestAFNIHeader: module = brikhead test_files = EXAMPLE_IMAGES @@ -86,7 +86,7 @@ def test_makehead(self): self.module.AFNIHeader.from_header(tp['fname']) -class TestAFNIImage(object): +class TestAFNIImage: module = brikhead test_files = EXAMPLE_IMAGES @@ -127,7 +127,7 @@ def test_array_proxy_slicing(self): assert_array_equal(arr[sliceobj], prox[sliceobj]) -class TestBadFiles(object): +class TestBadFiles: module = brikhead test_files = EXAMPLE_BAD_IMAGES @@ -137,7 +137,7 @@ def test_brikheadfile(self): self.module.load(tp['head']) -class TestBadVars(object): +class TestBadVars: module = brikhead vars = ['type = badtype-attribute\nname = BRICK_TYPES\ncount = 1\n1\n', 'type = integer-attribute\ncount = 1\n1\n'] diff --git a/nibabel/tests/test_deprecated.py b/nibabel/tests/test_deprecated.py index fe645154be..c09fda4988 100644 --- a/nibabel/tests/test_deprecated.py +++ b/nibabel/tests/test_deprecated.py @@ -32,7 +32,7 @@ def test_module_proxy(): def test_futurewarning_mixin(): # Test mixin for FutureWarning - class C(object): + class C: def __init__(self, val): self.val = val diff --git a/nibabel/tests/test_deprecator.py b/nibabel/tests/test_deprecator.py index 12c5b36b92..2e7a0b9ba9 100644 --- a/nibabel/tests/test_deprecator.py +++ b/nibabel/tests/test_deprecator.py @@ -62,7 +62,7 @@ def func_doc_long(i, j): "A docstring\n\n Some text" -class TestDeprecatorFunc(object): +class TestDeprecatorFunc: """ Test deprecator function specified in ``dep_func`` """ dep_func = Deprecator(cmp_func) @@ -136,7 +136,7 @@ def test_dep_func(self): func() -class TestDeprecatorMaker(object): +class TestDeprecatorMaker: """ Test deprecator class creation with custom warnings and errors """ dep_maker = partial(Deprecator, cmp_func) diff --git a/nibabel/tests/test_ecat_data.py b/nibabel/tests/test_ecat_data.py index 1accd01a14..dcd812c52d 100644 --- a/nibabel/tests/test_ecat_data.py +++ b/nibabel/tests/test_ecat_data.py @@ -22,7 +22,7 @@ ECAT_TEST_PATH = pjoin(get_nibabel_data(), 'nipy-ecattest') -class TestNegatives(object): +class TestNegatives: opener = staticmethod(load) example_params = dict( fname=os.path.join(ECAT_TEST_PATH, 'ECAT7_testcaste_neg_values.v'), diff --git a/nibabel/tests/test_image_api.py b/nibabel/tests/test_image_api.py index e4287988d7..21c7b14086 100644 --- a/nibabel/tests/test_image_api.py +++ b/nibabel/tests/test_image_api.py @@ -481,7 +481,7 @@ def validate_mmap_parameter(self, imaker, params): del rt_img # to allow windows to delete the directory -class HeaderShapeMixin(object): +class HeaderShapeMixin: """ Tests that header shape can be set and got Add this one of your header supports ``get_data_shape`` and @@ -499,7 +499,7 @@ def validate_header_shape(self, imaker, params): assert img.header.get_data_shape() == new_shape -class AffineMixin(object): +class AffineMixin: """ Adds test of affine property, method Add this one if your image has an ``affine`` property. If so, it should diff --git a/nibabel/tests/test_keywordonly.py b/nibabel/tests/test_keywordonly.py index 26e21ce02d..0ef631dbf4 100644 --- a/nibabel/tests/test_keywordonly.py +++ b/nibabel/tests/test_keywordonly.py @@ -33,7 +33,7 @@ def kw_func(an_arg, a_kwarg='thing'): kw_func(1, akeyarg=3) assert kw_func.__doc__ == 'Another docstring' - class C(object): + class C: @kw_only_meth(1) def kw_meth(self, an_arg, a_kwarg='thing'): diff --git a/nibabel/tests/test_minc1.py b/nibabel/tests/test_minc1.py index 829523c4c9..4fecf5782e 100644 --- a/nibabel/tests/test_minc1.py +++ b/nibabel/tests/test_minc1.py @@ -103,7 +103,7 @@ ] -class _TestMincFile(object): +class _TestMincFile: module = minc1 file_class = Minc1File fname = EG_FNAME diff --git a/nibabel/tests/test_minc2_data.py b/nibabel/tests/test_minc2_data.py index ebd53d7ced..fda6c1f8ec 100644 --- a/nibabel/tests/test_minc2_data.py +++ b/nibabel/tests/test_minc2_data.py @@ -34,7 +34,7 @@ def _make_affine(coses, zooms, starts): return affine -class TestEPIFrame(object): +class TestEPIFrame: opener = staticmethod(top_load) x_cos = [1, 0, 0] y_cos = [0., 1, 0] diff --git a/nibabel/tests/test_nifti1.py b/nibabel/tests/test_nifti1.py index 8ed897b036..63cf13c103 100644 --- a/nibabel/tests/test_nifti1.py +++ b/nibabel/tests/test_nifti1.py @@ -1387,7 +1387,7 @@ def test_nifti_dicom_extension(): Nifti1DicomExtension(2, 0) -class TestNifti1General(object): +class TestNifti1General: """ Test class to test nifti1 in general Tests here which mix the pair and the single type, and that should only be diff --git a/nibabel/tests/test_nifti2.py b/nibabel/tests/test_nifti2.py index dbc187f039..106e3ec787 100644 --- a/nibabel/tests/test_nifti2.py +++ b/nibabel/tests/test_nifti2.py @@ -26,7 +26,7 @@ image_file = os.path.join(data_path, 'example_nifti2.nii.gz') -class _Nifti2Mixin(object): +class _Nifti2Mixin: example_file = header_file sizeof_hdr = Nifti2Header.sizeof_hdr quat_dtype = np.float64 diff --git a/nibabel/tests/test_openers.py b/nibabel/tests/test_openers.py index 541af368c5..0a687353e3 100644 --- a/nibabel/tests/test_openers.py +++ b/nibabel/tests/test_openers.py @@ -34,7 +34,7 @@ pyzstd, HAVE_ZSTD, _ = optional_package("pyzstd") -class Lunk(object): +class Lunk: # bare file-like for testing closed = False diff --git a/nibabel/tests/test_parrec.py b/nibabel/tests/test_parrec.py index 9a8f2b1dfc..f40bf3b80a 100644 --- a/nibabel/tests/test_parrec.py +++ b/nibabel/tests/test_parrec.py @@ -728,7 +728,7 @@ def test_image_creation(): assert_array_equal(img.dataobj, arr_prox_fp) -class FakeHeader(object): +class FakeHeader: """ Minimal API of header for PARRECArrayProxy """ diff --git a/nibabel/tests/test_recoder.py b/nibabel/tests/test_recoder.py index 713e192707..127a7b0704 100644 --- a/nibabel/tests/test_recoder.py +++ b/nibabel/tests/test_recoder.py @@ -85,7 +85,7 @@ def test_recoder_6(): def test_custom_dicter(): # Allow custom dict-like object in constructor - class MyDict(object): + class MyDict: def __init__(self): self._keys = [] diff --git a/nibabel/tests/test_spatialimages.py b/nibabel/tests/test_spatialimages.py index dd707aa242..e7cad0de2c 100644 --- a/nibabel/tests/test_spatialimages.py +++ b/nibabel/tests/test_spatialimages.py @@ -69,7 +69,7 @@ def test_from_header(): assert hdr == copy assert hdr is not copy - class C(object): + class C: def get_data_dtype(self): return np.dtype('u2') @@ -188,7 +188,7 @@ class CHeader(SpatialHeader): assert (data == data2).all() -class DataLike(object): +class DataLike: # Minimal class implementing 'data' API shape = (3,) @@ -530,7 +530,7 @@ def test_slicer(self): assert (sliced_data == img.get_fdata()[sliceobj]).all() -class MmapImageMixin(object): +class MmapImageMixin: """ Mixin for testing images that may return memory maps """ #: whether to test mode of returned memory map check_mmap_mode = True diff --git a/nibabel/tests/test_spm99analyze.py b/nibabel/tests/test_spm99analyze.py index 492faf1d51..d2ba898fa6 100644 --- a/nibabel/tests/test_spm99analyze.py +++ b/nibabel/tests/test_spm99analyze.py @@ -47,7 +47,7 @@ NUMERIC_TYPES = CFLOAT_TYPES + IUINT_TYPES -class HeaderScalingMixin(object): +class HeaderScalingMixin: """ Mixin to add scaling tests to header tests Needs to be a mixin so nifti tests can use this method without inheriting @@ -155,7 +155,7 @@ def test_origin_checks(self): assert dxer(hdr.binaryblock) == 'very large origin values relative to dims' -class ImageScalingMixin(object): +class ImageScalingMixin: # Mixin to add scaling checks to image test class # Nifti tests inherits from Analyze tests not Spm Analyze tests. We need # these tests for Nifti scaling, hence the mixin. diff --git a/nibabel/tmpdirs.py b/nibabel/tmpdirs.py index c7452027bb..10b5ee78f5 100644 --- a/nibabel/tmpdirs.py +++ b/nibabel/tmpdirs.py @@ -13,7 +13,7 @@ from tempfile import template, mkdtemp -class TemporaryDirectory(object): +class TemporaryDirectory: """Create and return a temporary directory. This has the same behavior as mkdtemp but can be used as a context manager. @@ -81,7 +81,7 @@ def __exit__(self, exc, value, tb): return super(InTemporaryDirectory, self).__exit__(exc, value, tb) -class InGivenDirectory(object): +class InGivenDirectory: """ Change directory to given directory for duration of ``with`` block Useful when you want to use `InTemporaryDirectory` for the final test, but diff --git a/nibabel/tripwire.py b/nibabel/tripwire.py index abb54268d4..db659df337 100644 --- a/nibabel/tripwire.py +++ b/nibabel/tripwire.py @@ -29,7 +29,7 @@ def is_tripwire(obj): return False -class TripWire(object): +class TripWire: """ Class raising error if used Standard use is to proxy modules that we could not import diff --git a/nibabel/viewers.py b/nibabel/viewers.py index e435ac4ac9..65e813ef0f 100644 --- a/nibabel/viewers.py +++ b/nibabel/viewers.py @@ -12,7 +12,7 @@ from .orientations import aff2axcodes, axcodes2ornt -class OrthoSlicer3D(object): +class OrthoSlicer3D: """ Orthogonal-plane slice viewer. OrthoSlicer3d expects 3- or 4-dimensional array data. It treats diff --git a/nibabel/volumeutils.py b/nibabel/volumeutils.py index abbcfc1afd..dc82287dbb 100644 --- a/nibabel/volumeutils.py +++ b/nibabel/volumeutils.py @@ -48,7 +48,7 @@ COMPRESSED_FILE_LIKES = (*COMPRESSED_FILE_LIKES, pyzstd.ZstdFile) -class Recoder(object): +class Recoder: """ class to return canonical code(s) from code or aliases The concept is a lot easier to read in the implementation and @@ -224,7 +224,7 @@ def value_set(self, name=None): endian_codes = Recoder(endian_codes) -class DtypeMapper(object): +class DtypeMapper: """ Specialized mapper for numpy dtypes We pass this mapper into the Recoder class to deal with numpy dtype @@ -307,7 +307,7 @@ def pretty_mapping(mapping, getterfunc=None): >>> d = {'a key': 'a value'} >>> print(pretty_mapping(d)) a key : a value - >>> class C(object): # to control ordering, show get_ method + >>> class C: # to control ordering, show get_ method ... def __iter__(self): ... return iter(('short_field','longer_field')) ... def __getitem__(self, key): diff --git a/nibabel/wrapstruct.py b/nibabel/wrapstruct.py index af64a762c3..c0c13710d6 100644 --- a/nibabel/wrapstruct.py +++ b/nibabel/wrapstruct.py @@ -121,7 +121,7 @@ class WrapStructError(Exception): pass -class WrapStruct(object): +class WrapStruct: # placeholder datatype template_dtype = np.dtype([('integer', 'i2')]) diff --git a/nibabel/xmlutils.py b/nibabel/xmlutils.py index 1eb7e0ca02..d907f95e10 100644 --- a/nibabel/xmlutils.py +++ b/nibabel/xmlutils.py @@ -17,7 +17,7 @@ from .filebasedimages import FileBasedHeader -class XmlSerializable(object): +class XmlSerializable: """ Basic interface for serializing an object to xml""" def _to_xml_element(self): @@ -35,7 +35,7 @@ class XmlBasedHeader(FileBasedHeader, XmlSerializable): """ Basic wrapper around FileBasedHeader and XmlSerializable.""" -class XmlParser(object): +class XmlParser: """ Base class for defining how to parse xml-based image snippets. Image-specific parsers should define: diff --git a/nisext/sexts.py b/nisext/sexts.py index 37a8adcc7c..602572280d 100644 --- a/nisext/sexts.py +++ b/nisext/sexts.py @@ -260,7 +260,7 @@ def run(self): fobj.write(bat_contents) -class Bunch(object): +class Bunch: def __init__(self, vars): for key, name in vars.items(): if key.startswith('__'):