Skip to content

Commit

Permalink
STY: isort
Browse files Browse the repository at this point in the history
[git-blame-ignore-rev]
  • Loading branch information
effigies committed Jul 27, 2022
1 parent e9c28a2 commit fd47cf1
Show file tree
Hide file tree
Showing 175 changed files with 900 additions and 1,003 deletions.
43 changes: 20 additions & 23 deletions nibabel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import os

from .pkg_info import __version__
from .info import long_description as __doc__
from .pkg_info import __version__

__doc__ += """
Quickstart
Expand Down Expand Up @@ -39,40 +39,37 @@

# module imports
from . import analyze as ana
from . import spm99analyze as spm99
from . import spm2analyze as spm2
from . import ecat, mriutils
from . import nifti1 as ni1
from . import ecat
from . import spm2analyze as spm2
from . import spm99analyze as spm99
from . import streamlines, viewers
from .analyze import AnalyzeHeader, AnalyzeImage
from .arrayproxy import is_proxy
from .cifti2 import Cifti2Header, Cifti2Image

# object imports
from .fileholders import FileHolder, FileHolderError
from .freesurfer import MGHImage
from .funcs import as_closest_canonical, concat_images, four_to_three, squeeze_image
from .gifti import GiftiImage
from .imageclasses import all_image_classes, class_map, ext_map
from .loadsave import load, save
from .arrayproxy import is_proxy
from .analyze import AnalyzeHeader, AnalyzeImage
from .spm99analyze import Spm99AnalyzeHeader, Spm99AnalyzeImage
from .spm2analyze import Spm2AnalyzeHeader, Spm2AnalyzeImage
from .nifti1 import Nifti1Header, Nifti1Image, Nifti1Pair
from .nifti2 import Nifti2Header, Nifti2Image, Nifti2Pair
from .minc1 import Minc1Image
from .minc2 import Minc2Image
from .cifti2 import Cifti2Header, Cifti2Image
from .gifti import GiftiImage
from .freesurfer import MGHImage
from .funcs import squeeze_image, concat_images, four_to_three, as_closest_canonical
from .nifti1 import Nifti1Header, Nifti1Image, Nifti1Pair
from .nifti2 import Nifti2Header, Nifti2Image, Nifti2Pair
from .orientations import (
io_orientation,
orientation_affine,
flip_axis,
OrientationError,
apply_orientation,
aff2axcodes,
apply_orientation,
flip_axis,
io_orientation,
orientation_affine,
)
from .imageclasses import class_map, ext_map, all_image_classes
from . import mriutils
from . import streamlines
from . import viewers

from .pkg_info import get_pkg_info as _get_pkg_info
from .spm2analyze import Spm2AnalyzeHeader, Spm2AnalyzeImage
from .spm99analyze import Spm99AnalyzeHeader, Spm99AnalyzeImage


def get_info():
Expand Down
4 changes: 2 additions & 2 deletions nibabel/affines.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""Utility routines for working with points and affine transforms
"""
import numpy as np

from functools import reduce

import numpy as np


class AffineError(ValueError):
"""Errors in calculating or using affines"""
Expand Down
20 changes: 10 additions & 10 deletions nibabel/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,21 @@

import numpy as np

from .arrayproxy import ArrayProxy
from .arraywriters import ArrayWriter, WriterError, get_slope_inter, make_array_writer
from .batteryrunners import Report
from .fileholders import copy_file_map
from .spatialimages import HeaderDataError, HeaderTypeError, SpatialImage
from .volumeutils import (
native_code,
swapped_code,
make_dt_codes,
shape_zoom_affine,
apply_read_scaling,
array_from_file,
make_dt_codes,
native_code,
seek_tell,
apply_read_scaling,
shape_zoom_affine,
swapped_code,
)
from .arraywriters import make_array_writer, get_slope_inter, WriterError, ArrayWriter
from .wrapstruct import LabeledWrapStruct
from .spatialimages import HeaderDataError, HeaderTypeError, SpatialImage
from .fileholders import copy_file_map
from .batteryrunners import Report
from .arrayproxy import ArrayProxy

# Sub-parts of standard analyze header from
# Mayo dbh.h file
Expand Down
7 changes: 3 additions & 4 deletions nibabel/arrayproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@

import numpy as np

from .volumeutils import array_from_file, apply_read_scaling
from .fileslice import fileslice, canonical_slicers
from . import openers

from .fileslice import canonical_slicers, fileslice
from .volumeutils import apply_read_scaling, array_from_file

"""This flag controls whether a new file handle is created every time an image
is accessed through an ``ArrayProxy``, or a single file handle is created and
Expand Down Expand Up @@ -389,8 +388,8 @@ def reshape(self, shape):
size = np.prod(self._shape)

# Calculate new shape if not fully specified
from operator import mul
from functools import reduce
from operator import mul

n_unknowns = len([e for e in shape if e == -1])
if n_unknowns > 1:
Expand Down
10 changes: 5 additions & 5 deletions nibabel/arraywriters.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ def __init__(self, array, out_dtype=None)
import numpy as np

from .casting import (
int_to_float,
as_int,
int_abs,
type_info,
floor_exact,
best_float,
floor_exact,
int_abs,
int_to_float,
shared_range,
type_info,
)
from .volumeutils import finite_range, array_to_file
from .deprecator import ExpiredDeprecationError
from .volumeutils import array_to_file, finite_range


class WriterError(Exception):
Expand Down
5 changes: 2 additions & 3 deletions nibabel/benchmarks/bench_array_to_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
from io import BytesIO # NOQA

import numpy as np

from .butils import print_git_title

from numpy.testing import measure

from nibabel.volumeutils import array_to_file # NOQA

from .butils import print_git_title


def bench_array_to_file():
rng = np.random.RandomState(20111001)
Expand Down
9 changes: 5 additions & 4 deletions nibabel/benchmarks/bench_arrayproxy_slicing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@
pytest -c <path>/benchmarks/pytest.benchmark.ini <path>/benchmarks/bench_arrayproxy_slicing.py
"""

from timeit import timeit
import gc
import itertools as it
import numpy as np
from timeit import timeit
from unittest import mock

import numpy as np

import nibabel as nib
from nibabel.tmpdirs import InTemporaryDirectory
from nibabel.openers import HAVE_INDEXED_GZIP
from nibabel.tmpdirs import InTemporaryDirectory

from .butils import print_git_title
from ..rstutils import rst_table
from .butils import print_git_title

# if memory_profiler is installed, we get memory usage results
try:
Expand Down
6 changes: 3 additions & 3 deletions nibabel/benchmarks/bench_fileslice.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
"""

import sys
from io import BytesIO
from timeit import timeit

import numpy as np

from io import BytesIO
from ..openers import ImageOpener
from ..fileslice import fileslice
from ..openers import ImageOpener
from ..optpkg import optional_package
from ..rstutils import rst_table
from ..tmpdirs import InTemporaryDirectory
from ..optpkg import optional_package

SHAPE = (64, 64, 32, 100)
ROW_NAMES = [f'axis {i}, len {dim}' for i, dim in enumerate(SHAPE)]
Expand Down
6 changes: 2 additions & 4 deletions nibabel/benchmarks/bench_finite_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@
import sys

import numpy as np


from .butils import print_git_title

from numpy.testing import measure

from nibabel.volumeutils import finite_range # NOQA

from .butils import print_git_title


def bench_finite_range():
rng = np.random.RandomState(20111001)
Expand Down
7 changes: 2 additions & 5 deletions nibabel/benchmarks/bench_load_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@
"""

import sys
from io import BytesIO

import numpy as np

from io import BytesIO
from numpy.testing import measure

from .. import Nifti1Image

from .butils import print_git_title

from numpy.testing import measure


def bench_load_save():
rng = np.random.RandomState(20111001)
Expand Down
4 changes: 2 additions & 2 deletions nibabel/brikhead.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
programs (e.g., example4d+orig'[0]').
"""

from copy import deepcopy
import os
import re
from copy import deepcopy

import numpy as np

from .arrayproxy import ArrayProxy
from .fileslice import strided_scalar
from .spatialimages import SpatialImage, SpatialHeader, HeaderDataError, ImageDataError
from .spatialimages import HeaderDataError, ImageDataError, SpatialHeader, SpatialImage
from .volumeutils import Recoder

# used for doc-tests
Expand Down
2 changes: 1 addition & 1 deletion nibabel/casting.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import warnings
from numbers import Integral
from platform import processor, machine
from platform import machine, processor

import numpy as np

Expand Down
18 changes: 9 additions & 9 deletions nibabel/cifti2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@
cifti2_axes
"""

from .parse_cifti2 import Cifti2Extension
from .cifti2 import (
Cifti2MetaData,
CIFTI_BRAIN_STRUCTURES,
CIFTI_MODEL_TYPES,
Cifti2BrainModel,
Cifti2Header,
Cifti2HeaderError,
Cifti2Image,
Cifti2Label,
Cifti2LabelTable,
Cifti2VertexIndices,
Cifti2VoxelIndicesIJK,
Cifti2BrainModel,
Cifti2Matrix,
Cifti2MatrixIndicesMap,
Cifti2MetaData,
Cifti2NamedMap,
Cifti2Parcel,
Cifti2Surface,
Cifti2TransformationMatrixVoxelIndicesIJKtoXYZ,
Cifti2VertexIndices,
Cifti2Vertices,
Cifti2Volume,
CIFTI_BRAIN_STRUCTURES,
Cifti2HeaderError,
CIFTI_MODEL_TYPES,
Cifti2VoxelIndicesIJK,
load,
save,
)
from .cifti2_axes import Axis, BrainModelAxis, ParcelsAxis, SeriesAxis, LabelAxis, ScalarAxis
from .cifti2_axes import Axis, BrainModelAxis, LabelAxis, ParcelsAxis, ScalarAxis, SeriesAxis
from .parse_cifti2 import Cifti2Extension
12 changes: 6 additions & 6 deletions nibabel/cifti2/cifti2.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
http://www.nitrc.org/projects/cifti
"""
import re
from collections.abc import MutableSequence, MutableMapping, Iterable
from collections import OrderedDict
from collections.abc import Iterable, MutableMapping, MutableSequence
from warnings import warn

import numpy as np

from .. import xmlutils as xml
from ..filebasedimages import FileBasedHeader, SerializableImage
from ..dataobj_images import DataobjImage
from ..nifti1 import Nifti1Extensions
from ..nifti2 import Nifti2Image, Nifti2Header
from ..arrayproxy import reshape_dataobj
from ..caret import CaretMetaData
from ..dataobj_images import DataobjImage
from ..filebasedimages import FileBasedHeader, SerializableImage
from ..nifti1 import Nifti1Extensions
from ..nifti2 import Nifti2Header, Nifti2Image
from ..volumeutils import make_dt_codes


Expand Down Expand Up @@ -1473,7 +1473,7 @@ def from_file_map(klass, file_map, *, mmap=True, keep_file_open=None):
img : Cifti2Image
Returns a Cifti2Image
"""
from .parse_cifti2 import _Cifti2AsNiftiImage, Cifti2Extension
from .parse_cifti2 import Cifti2Extension, _Cifti2AsNiftiImage

nifti_img = _Cifti2AsNiftiImage.from_file_map(
file_map, mmap=mmap, keep_file_open=keep_file_open
Expand Down
6 changes: 4 additions & 2 deletions nibabel/cifti2/cifti2_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,12 @@
... bm_cortex)))
<class 'nibabel.cifti2.cifti2.Cifti2Header'>
"""
import abc
from operator import xor

import numpy as np

from . import cifti2
from operator import xor
import abc


def from_index_mapping(mim):
Expand Down
Loading

0 comments on commit fd47cf1

Please sign in to comment.