diff --git a/fsl/data/image.py b/fsl/data/image.py index 036d0575e6df95e977a3c9f26ee38747439cfe82..1b407a3f7c773066c13e75b5bb207de03986f9c3 100644 --- a/fsl/data/image.py +++ b/fsl/data/image.py @@ -814,7 +814,8 @@ class Image(Nifti): if indexed is not False: warnings.warn('The indexed argument is deprecated ' 'and has no effect', - category=DeprecationWarning) + category=DeprecationWarning, + stacklevel=2) if loadData: threaded = False diff --git a/fsl/data/imagewrapper.py b/fsl/data/imagewrapper.py index eccf8518485bdbb921f4c010db1bf197962f21e2..b73cb879aaf88ffa1e742477b3625fd7da91a590 100644 --- a/fsl/data/imagewrapper.py +++ b/fsl/data/imagewrapper.py @@ -37,9 +37,10 @@ get their definitions straight: """ -import logging -import collections -import itertools as it +import logging +import collections +import collections.abc as abc +import itertools as it import numpy as np import nibabel as nib @@ -689,7 +690,7 @@ class ImageWrapper(notifier.Notifier): # If we are slicing a scalar, the # assigned value has to be scalar. - if expNdims == 0 and isinstance(values, collections.Sequence): + if expNdims == 0 and isinstance(values, abc.Sequence): if len(values) > 1: raise IndexError('Invalid assignment: [{}] = {}'.format( @@ -828,7 +829,7 @@ def sliceObjToSliceTuple(sliceobj, shape): # The sliceobj could be a single sliceobj # or integer, instead of a tuple - if not isinstance(sliceobj, collections.Sequence): + if not isinstance(sliceobj, abc.Sequence): sliceobj = [sliceobj] # Turn e.g. array[6] into array[6, :, :] diff --git a/fsl/utils/transform.py b/fsl/utils/transform.py index 2a5610dd89c172bec7b349d6e3400ad3b3cf21f6..f574eaa764a8e337cb7616f7eaef254e0dfd3a9d 100644 --- a/fsl/utils/transform.py +++ b/fsl/utils/transform.py @@ -34,9 +34,9 @@ And a few more functions are provided for working with vectors: normalise """ -import numpy as np -import numpy.linalg as linalg -import collections +import numpy as np +import numpy.linalg as linalg +import collections.abc as abc def invert(x): @@ -94,7 +94,7 @@ def scaleOffsetXform(scales, offsets): :returns: A ``numpy.float32`` array of size :math:`4 \\times 4`. """ - oktypes = (collections.Sequence, np.ndarray) + oktypes = (abc.Sequence, np.ndarray) if not isinstance(scales, oktypes): scales = [scales] if not isinstance(offsets, oktypes): offsets = [offsets] @@ -398,7 +398,7 @@ def axisBounds(shape, if axes is None: axes = [0, 1, 2] - elif not isinstance(axes, collections.Iterable): + elif not isinstance(axes, abc.Iterable): scalar = True axes = [axes] @@ -507,13 +507,13 @@ def _fillPoints(p, axes): or an ``N*2`` or ``N*3`` array. """ - if not isinstance(p, collections.Iterable): p = [p] + if not isinstance(p, abc.Iterable): p = [p] p = np.array(p) if axes is None: return p - if not isinstance(axes, collections.Iterable): axes = [axes] + if not isinstance(axes, abc.Iterable): axes = [axes] if p.ndim == 1: p = p.reshape((len(p), 1))