Skip to content

Commit

Permalink
Use same black as CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasteuwen committed Feb 23, 2024
1 parent dbb1acd commit e711df2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 27 deletions.
18 changes: 6 additions & 12 deletions dlup/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,10 @@ 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 @@ -285,12 +283,10 @@ 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 @@ -553,12 +549,10 @@ 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: 2 additions & 4 deletions dlup/tiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,10 @@ 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: 4 additions & 8 deletions dlup/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ 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 @@ -61,12 +59,10 @@ 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: 1 addition & 3 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ 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 e711df2

Please sign in to comment.