Skip to content

Commit

Permalink
Reformatting based on new black
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasteuwen committed Feb 23, 2024
1 parent 88bbec0 commit dbb1acd
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
18 changes: 12 additions & 6 deletions dlup/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,12 @@ def __len__(self) -> int:
return self.cumulative_sizes[-1]

@overload
def __getitem__(self, index: int) -> T_co: ...
def __getitem__(self, index: int) -> T_co:
...

@overload
def __getitem__(self, index: slice) -> list[T_co]: ...
def __getitem__(self, index: slice) -> list[T_co]:
...

def __getitem__(self, index: Union[int, slice]) -> T_co | list[T_co]:
"""Returns the sample at the given index."""
Expand Down Expand Up @@ -283,10 +285,12 @@ def slide_image(self) -> "SlideImage":
)

@overload
def __getitem__(self, index: int) -> TileSample: ...
def __getitem__(self, index: int) -> TileSample:
...

@overload
def __getitem__(self, index: slice) -> Sequence[TileSample]: ...
def __getitem__(self, index: slice) -> Sequence[TileSample]:
...

def __getitem__(self, index: Union[int, slice]) -> Union[TileSample, Sequence[TileSample]]:
if isinstance(index, slice):
Expand Down Expand Up @@ -549,10 +553,12 @@ def from_standard_tiling(
)

@overload
def __getitem__(self, index: int) -> RegionFromWsiDatasetSample: ...
def __getitem__(self, index: int) -> RegionFromWsiDatasetSample:
...

@overload
def __getitem__(self, index: slice) -> list[RegionFromWsiDatasetSample]: ...
def __getitem__(self, index: slice) -> list[RegionFromWsiDatasetSample]:
...

def __getitem__(
self, index: Union[int, slice]
Expand Down
6 changes: 4 additions & 2 deletions dlup/tiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,12 @@ def size(self) -> tuple[int, int]:
return len(self.coordinates[0]), len(self.coordinates[1])

@overload
def __getitem__(self, key: int) -> npt.NDArray[np.int_ | np.float_]: ...
def __getitem__(self, key: int) -> npt.NDArray[np.int_ | np.float_]:
...

@overload
def __getitem__(self, key: slice) -> list[npt.NDArray[np.int_ | np.float_]]: ...
def __getitem__(self, key: slice) -> list[npt.NDArray[np.int_ | np.float_]]:
...

def __getitem__(
self, key: Union[int, slice]
Expand Down
12 changes: 8 additions & 4 deletions dlup/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ def __len__(self) -> int:
return len(self._sequence)

@overload
def __getitem__(self, key: int) -> T: ...
def __getitem__(self, key: int) -> T:
...

@overload
def __getitem__(self, key: slice) -> Sequence[T]: ...
def __getitem__(self, key: slice) -> Sequence[T]:
...

def __getitem__(self, key: Union[int, slice]) -> Union[T, Sequence[T]]:
if isinstance(key, slice):
Expand All @@ -59,10 +61,12 @@ def __init__(self, sequences: List[Sequence[T]]) -> None:
self._len = cumsum[-1]

@overload
def __getitem__(self, key: int) -> T: ...
def __getitem__(self, key: int) -> T:
...

@overload
def __getitem__(self, key: slice) -> Sequence[T]: ...
def __getitem__(self, key: slice) -> Sequence[T]:
...

def __getitem__(self, key: Union[int, slice]) -> Union[T, Sequence[T]]:
if isinstance(key, slice):
Expand Down
4 changes: 3 additions & 1 deletion tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ def level_dimensions(self):
@property
def level_spacings(self):
spacing = self.spacing
return tuple((spacing[0] * downsample**2, spacing[1] * downsample**2) for downsample in self.level_downsamples)
return tuple(
(spacing[0] * downsample**2, spacing[1] * downsample**2) for downsample in self.level_downsamples
)

def get_level_image(self, level):
return self.image.resize(self.level_dimensions[level])
Expand Down

0 comments on commit dbb1acd

Please sign in to comment.