Skip to content

Commit

Permalink
♻️ Refactor typing to type_hints.
Browse files Browse the repository at this point in the history
  • Loading branch information
shaneahmed committed Feb 4, 2025
1 parent c0b8c1c commit 6b3b10c
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion tests/test_annotation_stores.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
if TYPE_CHECKING: # pragma: no cover
from numbers import Number

from tiatoolbox.typing import Geometry
from tiatoolbox.type_hints import Geometry


sqlite3.enable_callback_tracebacks(True) # noqa: FBT003
Expand Down
2 changes: 1 addition & 1 deletion tests/test_patch_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
)

if TYPE_CHECKING:
from tiatoolbox.typing import IntPair, Resolution, Units
from tiatoolbox.type_hints import IntPair, Resolution, Units


def read_points_patches(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from tiatoolbox.utils.transforms import locsize2bounds

if TYPE_CHECKING:
from tiatoolbox.typing import IntBounds
from tiatoolbox.type_hints import IntBounds

RNG = np.random.default_rng() # Numpy Random Generator

Expand Down
2 changes: 1 addition & 1 deletion tests/test_wsireader.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import requests
from openslide import OpenSlide

from tiatoolbox.typing import IntBounds, IntPair
from tiatoolbox.type_hints import IntBounds, IntPair
from tiatoolbox.wsicore.wsimeta import WSIMeta

# -------------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions tiatoolbox/annotation/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@
py_regexp,
)
from tiatoolbox.enums import GeometryType
from tiatoolbox.typing import CallablePredicate, CallableSelect, Geometry
from tiatoolbox.type_hints import CallablePredicate, CallableSelect, Geometry

if TYPE_CHECKING: # pragma: no cover
from tiatoolbox.typing import (
from tiatoolbox.type_hints import (
Predicate,
Properties,
QueryGeometry,
Expand Down
2 changes: 1 addition & 1 deletion tiatoolbox/models/architecture/nuclick.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from tiatoolbox.models.models_abc import ModelABC

if TYPE_CHECKING: # pragma: no cover
from tiatoolbox.typing import IntPair
from tiatoolbox.type_hints import IntPair

bn_axis = 1

Expand Down
2 changes: 1 addition & 1 deletion tiatoolbox/models/dataset/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import torch
from PIL.Image import Image

from tiatoolbox.typing import IntPair, Resolution, Units
from tiatoolbox.type_hints import IntPair, Resolution, Units


class _TorchPreprocCaller:
Expand Down
2 changes: 1 addition & 1 deletion tiatoolbox/models/engine/multi_task_segmentor.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
if TYPE_CHECKING: # pragma: no cover
import torch

from tiatoolbox.typing import IntBounds
from tiatoolbox.type_hints import IntBounds


# Python is yet to be able to natively pickle Object method/static method.
Expand Down
2 changes: 1 addition & 1 deletion tiatoolbox/models/engine/patch_predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from tiatoolbox.wsicore.wsireader import VirtualWSIReader, WSIReader

if TYPE_CHECKING: # pragma: no cover
from tiatoolbox.typing import IntPair, Resolution, Units
from tiatoolbox.type_hints import IntPair, Resolution, Units


class IOPatchPredictorConfig(IOSegmentorConfig):
Expand Down
2 changes: 1 addition & 1 deletion tiatoolbox/models/engine/semantic_segmentor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
if TYPE_CHECKING: # pragma: no cover
from multiprocessing.managers import Namespace

from tiatoolbox.typing import IntPair, Resolution, Units
from tiatoolbox.type_hints import IntPair, Resolution, Units


def _estimate_canvas_parameters(
Expand Down
2 changes: 1 addition & 1 deletion tiatoolbox/tools/patchextraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from pandas import DataFrame

from tiatoolbox.annotation.storage import AnnotationStore
from tiatoolbox.typing import Resolution, Units
from tiatoolbox.type_hints import Resolution, Units


def validate_shape(shape: np.ndarray) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion tiatoolbox/tools/registration/wsi_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from tiatoolbox.wsicore.wsireader import VirtualWSIReader, WSIReader

if TYPE_CHECKING: # pragma: no cover
from tiatoolbox.typing import IntBounds, Resolution, Units
from tiatoolbox.type_hints import IntBounds, Resolution, Units

RGB_IMAGE_DIM = 3
BIN_MASK_DIM = 2
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tiatoolbox/utils/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
)

if TYPE_CHECKING: # pragma: no cover
from tiatoolbox.typing import IntBounds, NumpyPadLiteral
from tiatoolbox.type_hints import IntBounds, NumpyPadLiteral

PADDING_TO_BOUNDS = np.array([-1, -1, 1, 1])
"""
Expand Down
2 changes: 1 addition & 1 deletion tiatoolbox/wsicore/wsimeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
if TYPE_CHECKING: # pragma: no cover
from collections.abc import Mapping, Sequence

from tiatoolbox.typing import Resolution, Units
from tiatoolbox.type_hints import Resolution, Units


class WSIMeta:
Expand Down
9 changes: 8 additions & 1 deletion tiatoolbox/wsicore/wsireader.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@

import glymur

from tiatoolbox.typing import Bounds, IntBounds, IntPair, NumPair, Resolution, Units
from tiatoolbox.type_hints import (
Bounds,
IntBounds,
IntPair,
NumPair,
Resolution,
Units,
)
from tiatoolbox.wsicore.metadata.ngff import Multiscales

pixman_warning()
Expand Down

0 comments on commit 6b3b10c

Please sign in to comment.