Skip to content

Commit 91d134d

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 2f88cb7 commit 91d134d

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

tests/engines/test_semantic_segmentor.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ def test_semantic_segmentor_patches(
8787
assert "probabilities" not in output.keys() # noqa: SIM118
8888

8989

90-
def test_save_annotation_store(sample_patch1: Path, sample_patch2: Path, tmp_path: Path):
90+
def test_save_annotation_store(
91+
sample_patch1: Path, sample_patch2: Path, tmp_path: Path
92+
):
9193
segmentor = SemanticSegmentor(
9294
model="fcn-tissue_mask", batch_size=32, verbose=False, device=device
9395
)
@@ -112,7 +114,9 @@ def test_save_annotation_store(sample_patch1: Path, sample_patch2: Path, tmp_pat
112114

113115

114116
def test_hovernet_dat() -> None:
115-
from tiatoolbox.utils.misc import store_from_dat
116117
from pathlib import Path
118+
119+
from tiatoolbox.utils.misc import store_from_dat
120+
117121
path_to_file = Path.cwd().parent.parent / "output" / "0.dat"
118122
out = store_from_dat(path_to_file, scale_factor=(1.0, 1.0))

tests/test_utils.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,9 @@ def test_patch_pred_store_cdict() -> None:
16921692
"other": "other",
16931693
}
16941694
class_dict = {0: "class0", 1: "class1"}
1695-
store = misc.dict_to_store_patch_predictions(patch_output, (1.0, 1.0), class_dict=class_dict)
1695+
store = misc.dict_to_store_patch_predictions(
1696+
patch_output, (1.0, 1.0), class_dict=class_dict
1697+
)
16961698

16971699
# Check that it is an SQLiteStore containing the expected annotations
16981700
assert isinstance(store, SQLiteStore)
@@ -1770,7 +1772,9 @@ def test_patch_pred_store_persist(tmp_path: pytest.TempPathFactory) -> None:
17701772
}
17711773
save_path = tmp_path / "patch_output" / "output.db"
17721774

1773-
store_path = misc.dict_to_store_patch_predictions(patch_output, (1.0, 1.0), save_path=save_path)
1775+
store_path = misc.dict_to_store_patch_predictions(
1776+
patch_output, (1.0, 1.0), save_path=save_path
1777+
)
17741778

17751779
print("Annotation store path: ", store_path)
17761780
assert Path.exists(store_path), "Annotation Store output file does not exist"
@@ -1804,7 +1808,9 @@ def test_patch_pred_store_persist_ext(tmp_path: pytest.TempPathFactory) -> None:
18041808
# sends the path of a jpeg source image, expects .db file in the same directory
18051809
save_path = tmp_path / "patch_output" / "output.jpeg"
18061810

1807-
store_path = misc.dict_to_store_patch_predictions(patch_output, (1.0, 1.0), save_path=save_path)
1811+
store_path = misc.dict_to_store_patch_predictions(
1812+
patch_output, (1.0, 1.0), save_path=save_path
1813+
)
18081814

18091815
print("Annotation store path: ", store_path)
18101816
assert Path.exists(store_path), "Annotation Store output file does not exist"

tiatoolbox/models/engine/semantic_segmentor_new.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
from __future__ import annotations
44

55
import shutil
6+
from pathlib import Path
67
from typing import TYPE_CHECKING
78

89
import zarr
910
from typing_extensions import Unpack
10-
from pathlib import Path
1111

12+
from ...utils.misc import dict_to_store_semantic_segmentor, dict_to_zarr
1213
from .patch_predictor import PatchPredictor, PredictorRunParams
13-
from ...utils.misc import dict_to_zarr, dict_to_store_semantic_segmentor
1414

1515
if TYPE_CHECKING: # pragma: no cover
1616
import os

tiatoolbox/utils/misc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,11 +1285,11 @@ def dict_to_store_semantic_segmentor(
12851285
origin = (0, 0)
12861286
scaled_coords = np.array([scale_factor * coords])
12871287
feature_geom = feature2geometry(
1288-
{
1289-
"type": "Polygon",
1290-
"coordinates": scaled_coords,
1291-
},
1292-
)
1288+
{
1289+
"type": "Polygon",
1290+
"coordinates": scaled_coords,
1291+
},
1292+
)
12931293
annotations.append(
12941294
Annotation(
12951295
geometry=make_valid_poly(

0 commit comments

Comments
 (0)