Skip to content

Commit 69b661c

Browse files
authored
Merge pull request #647 from FZJ-INM1-BDA/maint_pep8_import_order
Maint pep8 import order
2 parents 18cd2a0 + 9c2cb2e commit 69b661c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+279
-281
lines changed

siibra/__init__.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
import os as _os
17+
1618
from .commons import (
1719
logger,
1820
QUIET,
1921
VERBOSE,
2022
MapType,
21-
MapIndex,
2223
set_log_level,
2324
__version__
2425
)
25-
26+
from . import configuration, features, livequeries
27+
from .configuration import factory
2628
from .core import (
2729
atlas as _atlas,
2830
parcellation as _parcellation,
@@ -31,13 +33,9 @@
3133
from .volumes import parcellationmap as _parcellationmap
3234
from .retrieval.requests import CACHE as cache
3335
from .retrieval.cache import Warmup, WarmupLevel
36+
from .locations import Point, PointCloud, Plane, BoundingBox
3437

35-
from . import configuration
36-
from .configuration import factory
37-
from . import features, livequeries
38-
from siibra.locations import Point, PointCloud, Plane, BoundingBox
3938

40-
import os as _os
4139
logger.info(f"Version: {__version__}")
4240
logger.warning("This is a development release. Use at your own risk.")
4341
logger.info(

siibra/commons.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,26 @@
1717
import os
1818
import re
1919
from enum import Enum
20-
from nibabel import Nifti1Image
21-
from nilearn.image import resample_to_img
2220
import logging
23-
from tqdm import tqdm
24-
import numpy as np
25-
import pandas as pd
26-
from typing import Generic, Iterable, Iterator, List, TypeVar, Union, Dict, Generator, Tuple
27-
from skimage.filters import gaussian
2821
from dataclasses import dataclass
2922
from hashlib import md5
3023
from uuid import UUID
3124
import math
25+
from typing import Generic, Iterable, Iterator, List, TypeVar, Union, Dict, Generator, Tuple
3226
try:
3327
from typing import TypedDict
3428
except ImportError:
3529
# support python 3.7
3630
from typing_extensions import TypedDict
3731

32+
from tqdm import tqdm
33+
import numpy as np
34+
import pandas as pd
35+
from nibabel import Nifti1Image
36+
from nilearn.image import resample_to_img
37+
from skimage.filters import gaussian
38+
39+
3840
logging.addLevelName(21, "INFO_WO_PROGRESS_BARS")
3941
logger = logging.getLogger(__name__.split(os.path.extsep)[0])
4042
ch = logging.StreamHandler()

siibra/configuration/configuration.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
from ..commons import logger, __version__, SIIBRA_USE_CONFIGURATION, siibra_tqdm
17-
from ..retrieval.repositories import GitlabConnector, RepositoryConnector, GithubConnector
18-
from ..retrieval.exceptions import NoSiibraConfigMirrorsAvailableException
19-
from ..retrieval.requests import SiibraHttpRequestError
20-
2116
from typing import Union, List
2217
from collections import defaultdict
2318
from requests.exceptions import ConnectionError
2419
from os import path
2520

21+
from ..commons import logger, __version__, SIIBRA_USE_CONFIGURATION, siibra_tqdm
22+
from ..retrieval.repositories import GitlabConnector, RepositoryConnector, GithubConnector
23+
from ..retrieval.exceptions import NoSiibraConfigMirrorsAvailableException
24+
from ..retrieval.requests import SiibraHttpRequestError
25+
2626

2727
class Configuration:
2828
"""

siibra/configuration/factory.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
from os import path
17+
import json
18+
from typing import List, Dict, Callable
19+
from io import BytesIO
20+
from functools import wraps
21+
22+
import numpy as np
23+
import pandas as pd
24+
1625
from ..commons import logger, Species
1726
from ..features import anchor, connectivity
1827
from ..features.tabular import (
@@ -29,14 +38,6 @@
2938
from ..volumes import volume, sparsemap, parcellationmap
3039
from ..volumes.providers.provider import VolumeProvider
3140

32-
from os import path
33-
import json
34-
import numpy as np
35-
from typing import List, Dict, Callable
36-
import pandas as pd
37-
from io import BytesIO
38-
from functools import wraps
39-
4041

4142
_registered_build_fns: Dict[str, Callable] = {}
4243

siibra/core/assignment.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from enum import Enum
1818
from dataclasses import dataclass
1919
from typing import Dict, Generic, TypeVar, TYPE_CHECKING
20+
2021
if TYPE_CHECKING:
2122
from .structure import BrainStructure
2223

siibra/core/atlas.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
"""Provides reference systems for brains."""
16-
from . import concept, space as _space, parcellation as _parcellation
17-
18-
from ..commons import MapType, logger, InstanceTable, Species
1916

2017
from typing import List
2118

19+
from . import concept, space as _space, parcellation as _parcellation
20+
from ..commons import MapType, logger, InstanceTable, Species
21+
2222

2323
VERSION_BLACKLIST_WORDS = ["beta", "rc", "alpha"]
2424

siibra/core/concept.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
"""Parent class to siibra main concepts."""
16+
17+
import re
18+
from typing import TypeVar, Type, Union, List, TYPE_CHECKING, Dict
19+
1620
from ..commons import (
1721
create_key,
1822
clear_name,
@@ -23,8 +27,6 @@
2327
)
2428
from ..retrieval import cache
2529

26-
import re
27-
from typing import TypeVar, Type, Union, List, TYPE_CHECKING, Dict
2830

2931
T = TypeVar("T", bound="AtlasConcept")
3032
_REGISTRIES: Dict[Type[T], InstanceTable[T]] = {}

siibra/core/parcellation.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
"""Hierarchal brain regions and metadata."""
16-
from . import region
17-
18-
from ..commons import logger, MapType, Species
19-
from ..volumes import parcellationmap
20-
from ..exceptions import MapNotFound
2116

2217
from functools import lru_cache
2318
import re
@@ -28,6 +23,11 @@
2823
# support python 3.7
2924
from typing_extensions import Literal
3025

26+
from . import region
27+
from ..commons import logger, MapType, Species
28+
from ..volumes import parcellationmap
29+
from ..exceptions import MapNotFound
30+
3131

3232
if TYPE_CHECKING:
3333
from .space import Space

siibra/core/region.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@
1414
# limitations under the License.
1515
"""Representation of a brain region."""
1616

17+
import re
18+
from typing import List, Union, Iterable, Dict, Callable, Tuple, Set
19+
from difflib import SequenceMatcher
20+
import json
21+
from functools import wraps, reduce
22+
from concurrent.futures import ThreadPoolExecutor
23+
from functools import lru_cache
24+
25+
import anytree
26+
from ebrains_drive import BucketApiClient
27+
1728
from . import concept, structure, space as _space, parcellation as _parcellation, assignment
1829
from ..retrieval.cache import cache_user_fn
1930
from ..locations import location, pointcloud, boundingbox as _boundingbox
@@ -27,16 +38,6 @@
2738
)
2839
from ..exceptions import NoMapAvailableError, SpaceWarpingFailedError
2940

30-
import re
31-
import anytree
32-
from typing import List, Union, Iterable, Dict, Callable, Tuple, Set
33-
from difflib import SequenceMatcher
34-
from ebrains_drive import BucketApiClient
35-
import json
36-
from functools import wraps, reduce
37-
from concurrent.futures import ThreadPoolExecutor
38-
from functools import lru_cache
39-
4041

4142
REGEX_TYPE = type(re.compile("test"))
4243

siibra/core/space.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@
1414
# limitations under the License.
1515
"""A particular brain reference space."""
1616

17+
from typing import List, TYPE_CHECKING, Union
1718

1819
from . import concept
1920
from ..commons import logger, Species
2021

21-
from typing import List, TYPE_CHECKING, Union
22-
2322
if TYPE_CHECKING:
2423
from ..volumes import volume
2524

siibra/core/structure.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
bounding box in MNI space is a structure, but not an AtlasConcept.
2222
"""
2323

24-
from . import assignment, region as _region
25-
2624
from abc import ABC, abstractmethod
2725
from typing import Tuple, Dict
2826

27+
from . import assignment, region as _region
28+
2929

3030
class BrainStructure(ABC):
3131
"""Abstract base class for types who can act as a location filter."""

siibra/features/anchor.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,18 @@
1414
# limitations under the License.
1515
"""Handles the relation between study targets and BrainStructures."""
1616

17-
from ..commons import Species, logger
17+
from typing import Union, List, Dict, Iterable
1818

19+
from ..commons import Species, logger
1920
from ..core.structure import BrainStructure
2021
from ..core.assignment import AnatomicalAssignment, Qualification
2122
from ..locations.location import Location
2223
from ..core.parcellation import Parcellation, find_regions
2324
from ..core.region import Region
2425
from ..core.space import Space
2526
from ..exceptions import SpaceWarpingFailedError
26-
2727
from ..vocabularies import REGION_ALIASES
2828

29-
from typing import Union, List, Dict, Iterable
30-
3129

3230
class AnatomicalAnchor:
3331
"""

siibra/features/connectivity/regional_connectivity.py

+10-13
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,25 @@
1414
# limitations under the License.
1515

1616
from zipfile import ZipFile
17-
from ..feature import Feature, Compoundable
18-
from ..tabular.tabular import Tabular
17+
from typing import Callable, Union, List, Tuple, Iterator
18+
try:
19+
from typing import Literal
20+
except ImportError: # support python 3.7
21+
from typing_extensions import Literal
1922

20-
from .. import anchor as _anchor
23+
import numpy as np
24+
import pandas as pd
2125

26+
from .. import anchor as _anchor
27+
from ..feature import Feature, Compoundable
28+
from ..tabular.tabular import Tabular
2229
from ...commons import logger, QUIET, siibra_tqdm
2330
from ...core import region as _region
2431
from ...locations import pointcloud
2532
from ...retrieval.repositories import RepositoryConnector
2633
from ...retrieval.requests import HttpRequest
2734

2835

29-
import pandas as pd
30-
import numpy as np
31-
from typing import Callable, Union, List, Tuple, Iterator
32-
33-
try:
34-
from typing import Literal
35-
except ImportError: # support python 3.7
36-
from typing_extensions import Literal
37-
38-
3936
class RegionalConnectivity(Feature, Compoundable):
4037
"""
4138
Parcellation-averaged connectivity, providing one or more matrices of a

siibra/features/dataset/ebrains.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"""Non-preconfigured data features hosted at EBRAINS."""
1616

1717
from zipfile import ZipFile
18+
1819
from .. import anchor as _anchor
1920
from .. import feature
20-
2121
from ...retrieval import datasets
2222

2323

siibra/features/feature.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@
1414
# limitations under the License.
1515
"""Handles multimodal data features and related queries."""
1616

17-
from . import anchor as _anchor
18-
19-
from ..commons import logger, InstanceTable, siibra_tqdm, __version__
20-
from ..core import concept, space, region, parcellation, structure
21-
from ..volumes import volume
22-
2317
from typing import Union, TYPE_CHECKING, List, Dict, Type, Tuple, BinaryIO, Any, Iterator
2418
from hashlib import md5
2519
from collections import defaultdict
@@ -28,6 +22,11 @@
2822
from re import sub
2923
from textwrap import wrap
3024

25+
from . import anchor as _anchor
26+
from ..commons import logger, InstanceTable, siibra_tqdm, __version__
27+
from ..core import concept, space, region, parcellation, structure
28+
from ..volumes import volume
29+
3130
if TYPE_CHECKING:
3231
from ..retrieval.datasets import EbrainsDataset
3332
TypeDataset = EbrainsDataset

siibra/features/image/image.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414
# limitations under the License.
1515
"""Base type of features in volume format and related anatomical anchor."""
1616

17+
from typing import List, TYPE_CHECKING
1718
from zipfile import ZipFile
18-
from .. import feature
1919

20+
from .. import feature
2021
from .. import anchor as _anchor
21-
2222
from ...volumes import volume as _volume
2323

24-
from typing import List, TYPE_CHECKING
25-
2624
if TYPE_CHECKING:
2725
from ...locations.boundingbox import BoundingBox
2826
from ...volumes.providers import provider

siibra/features/image/sections.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
# limitations under the License.
1515
"""Multimodal data features in 2D section."""
1616

17-
from . import image
1817
from typing import TYPE_CHECKING
1918

19+
from . import image
20+
2021
if TYPE_CHECKING:
2122
from ...locations import AxisAlignedPatch, Contour
2223
from ...features.anchor import AnatomicalAnchor

siibra/features/tabular/bigbrain_intensity_profile.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
from typing import List, TYPE_CHECKING
17+
1618
from . import cortical_profile
1719

18-
from typing import List, TYPE_CHECKING
1920
if TYPE_CHECKING:
2021
from ...features.anchor import AnatomicalAnchor
2122

0 commit comments

Comments
 (0)