Skip to content

Commit

Permalink
refactor: replace aliases to types in collections
Browse files Browse the repository at this point in the history
  • Loading branch information
yzx9 committed Apr 5, 2024
1 parent b8eda2c commit 561ca7b
Show file tree
Hide file tree
Showing 22 changed files with 43 additions and 52 deletions.
3 changes: 2 additions & 1 deletion examples/pytorch/branch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Transformations in branch requires pytorch."""

from typing import Callable, Literal
from collections.abc import Callable
from typing import Literal

import numpy as np
import numpy.typing as npt
Expand Down
3 changes: 2 additions & 1 deletion examples/pytorch/branch_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import os
import warnings
from typing import Generic, Iterable, TypeVar, cast
from collections.abc import Iterable
from typing import Generic, TypeVar, cast

import torch
import torch.utils.data
Expand Down
3 changes: 2 additions & 1 deletion swcgeom/analysis/feature_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
"""

from abc import ABC, abstractmethod
from collections.abc import Callable
from functools import cached_property
from itertools import chain
from os.path import basename
from typing import Any, Callable, Literal, overload
from typing import Any, Literal, overload

import numpy as np
import numpy.typing as npt
Expand Down
3 changes: 2 additions & 1 deletion swcgeom/analysis/trunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

# pylint: disable=invalid-name

from collections.abc import Iterable
from itertools import chain
from typing import Any, Iterable, Literal, Optional, cast
from typing import Any, Literal, Optional, cast

import numpy as np
import numpy.typing as npt
Expand Down
3 changes: 2 additions & 1 deletion swcgeom/core/branch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Branch is a set of node points."""

from typing import Generic, Iterable
from collections.abc import Iterable
from typing import Generic

import numpy as np
import numpy.typing as npt
Expand Down
3 changes: 2 additions & 1 deletion swcgeom/core/compartment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""The segment is a branch with two nodes."""

from typing import Generic, Iterable, TypeVar
from collections.abc import Iterable
from typing import Generic, TypeVar

import numpy as np
import numpy.typing as npt
Expand Down
4 changes: 2 additions & 2 deletions swcgeom/core/node.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Nueron node."""

import warnings
from typing import Any, Generic, Iterable
from collections.abc import Iterable
from typing import Any, Generic

import numpy as np
import numpy.typing as npt
Expand Down
3 changes: 2 additions & 1 deletion swcgeom/core/path.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Nueron path."""

import warnings
from typing import Generic, Iterable, Iterator, overload
from collections.abc import Iterable, Iterator
from typing import Generic, overload

import numpy as np
import numpy.typing as npt
Expand Down
13 changes: 2 additions & 11 deletions swcgeom/core/population.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,10 @@

import os
import warnings
from collections.abc import Callable, Iterable, Iterator
from concurrent.futures import ProcessPoolExecutor
from functools import reduce
from typing import (
Any,
Callable,
Iterable,
Iterator,
Optional,
Protocol,
TypeVar,
cast,
overload,
)
from typing import Any, Optional, Protocol, TypeVar, cast, overload

import numpy as np
import numpy.typing as npt
Expand Down
3 changes: 2 additions & 1 deletion swcgeom/core/swc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import warnings
from abc import ABC, abstractmethod
from collections.abc import Iterable
from copy import deepcopy
from typing import Any, Iterable, Optional, TypeVar, overload
from typing import Any, Optional, TypeVar, overload

import numpy as np
import numpy.typing as npt
Expand Down
3 changes: 2 additions & 1 deletion swcgeom/core/swc_utils/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Base SWC format utils."""

from typing import Callable, Literal, NamedTuple, Optional, TypeVar, overload
from collections.abc import Callable
from typing import Literal, NamedTuple, Optional, TypeVar, overload

import numpy as np
import numpy.typing as npt
Expand Down
3 changes: 2 additions & 1 deletion swcgeom/core/swc_utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import re
import warnings
from typing import Callable, Iterable, Literal, Optional
from collections.abc import Callable, Iterable
from typing import Literal, Optional

import numpy as np
import numpy.typing as npt
Expand Down
3 changes: 2 additions & 1 deletion swcgeom/core/swc_utils/normalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
Methods ending with a underline imply an in-place transformation.
"""

from typing import Callable, Literal, Optional
from collections.abc import Callable
from typing import Literal, Optional

import numpy as np
import numpy.typing as npt
Expand Down
12 changes: 2 additions & 10 deletions swcgeom/core/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@

import itertools
import os
from typing import (
Callable,
Iterable,
Iterator,
Literal,
Optional,
TypeVar,
Union,
overload,
)
from collections.abc import Callable, Iterable, Iterator
from typing import Literal, Optional, TypeVar, Union, overload

import numpy as np
import numpy.typing as npt
Expand Down
3 changes: 2 additions & 1 deletion swcgeom/core/tree_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""SWC util wrapper for tree."""

import warnings
from typing import Callable, Iterable, Optional, TypeVar, overload
from collections.abc import Callable, Iterable
from typing import Optional, TypeVar, overload

import numpy as np

Expand Down
3 changes: 2 additions & 1 deletion swcgeom/images/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import os
import re
import warnings
from collections.abc import Callable, Iterable
from dataclasses import dataclass
from typing import Callable, Generic, Iterable, Literal, Optional, TypeVar, overload
from typing import Generic, Literal, Optional, TypeVar, overload

import numpy as np
import numpy.typing as npt
Expand Down
13 changes: 2 additions & 11 deletions swcgeom/images/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,9 @@
import re
import warnings
from abc import ABC, abstractmethod
from collections.abc import Callable, Iterable
from functools import cache, lru_cache
from typing import (
Any,
Callable,
Generic,
Iterable,
Literal,
Optional,
TypeVar,
cast,
overload,
)
from typing import Any, Generic, Literal, Optional, TypeVar, cast, overload

import nrrd
import numpy as np
Expand Down
3 changes: 2 additions & 1 deletion swcgeom/transforms/image_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
import os
import re
import time
from typing import Iterable, Optional
from collections.abc import Iterable
from typing import Optional

import numpy as np
import numpy.typing as npt
Expand Down
3 changes: 2 additions & 1 deletion swcgeom/transforms/tree.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Transformation in tree."""

import warnings
from typing import Callable, Optional
from collections.abc import Callable
from typing import Optional

import numpy as np

Expand Down
3 changes: 2 additions & 1 deletion swcgeom/transforms/tree_assembler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Assemble a tree."""

from collections.abc import Iterable
from copy import copy
from typing import Iterable, Optional
from typing import Optional

import numpy as np
import pandas as pd
Expand Down
3 changes: 2 additions & 1 deletion swcgeom/utils/neuromorpho.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
import math
import os
import urllib.parse
from typing import Any, Callable, Iterable, Literal, Optional
from collections.abc import Callable, Iterable
from typing import Any, Literal, Optional

from tqdm import tqdm

Expand Down
2 changes: 1 addition & 1 deletion swcgeom/utils/sdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import warnings
from abc import ABC, abstractmethod
from typing import Iterable
from collections.abc import Iterable

import numpy as np
import numpy.typing as npt
Expand Down

0 comments on commit 561ca7b

Please sign in to comment.