Skip to content

Commit 878a282

Browse files
Type layer_category as Literal everywhere (#454)
* introduce literal * fix import and properties * remove LayerCategories * fix imports * Update webknossos/Changelog.md Co-authored-by: Jonathan Striebel <[email protected]> * rename layer categories * Update test_dataset.py Co-authored-by: Jonathan Striebel <[email protected]>
1 parent 1339b68 commit 878a282

18 files changed

+152
-175
lines changed

webknossos/Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ For upgrade instructions, please check the respective *Breaking Changes* section
6262
[Commits](https://github.com/scalableminds/webknossos-cuber/compare/v0.8.16...v0.8.18)
6363

6464
### Breaking Changes
65+
- The class `LayerCategories` was removed. `COLOR_TYPE` and `SEGMENTATION_TYPE` were renamed to `COLOR_CATEGORY` and `SEGMENTATION_CATEGORY` and can now be imported directly. The type of many parameters were changed from `str` to the literal `LayerCategoryType`. [#454](https://github.com/scalableminds/webknossos-libs/pull/454)
6566
### Added
6667
- The Dataset class now has a new method: add_shallow_copy. [#437](https://github.com/scalableminds/webknossos-libs/pull/437)
6768
### Changed

webknossos/tests/test_buffered_slice_utils.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import numpy as np
77
import wkw
88

9-
from webknossos.dataset import Dataset, LayerCategories
9+
from webknossos.dataset import COLOR_CATEGORY, Dataset
1010
from webknossos.geometry import Mag, Vec3Int
1111

1212
TESTOUTPUT_DIR = Path("testoutput")
@@ -28,9 +28,9 @@ def test_buffered_slice_writer() -> None:
2828

2929
delete_dir(dataset_dir)
3030
ds = Dataset.create(dataset_dir, scale=(1, 1, 1))
31-
mag_view = ds.add_layer(
32-
"color", LayerCategories.COLOR_TYPE, dtype_per_channel=dtype
33-
).add_mag(mag)
31+
mag_view = ds.add_layer("color", COLOR_CATEGORY, dtype_per_channel=dtype).add_mag(
32+
mag
33+
)
3434

3535
with mag_view.get_buffered_slice_writer(origin) as writer:
3636
for i in range(13):
@@ -89,9 +89,7 @@ def test_buffered_slice_writer_along_different_axis(tmp_path: Path) -> None:
8989

9090
for dim in [0, 1, 2]:
9191
ds = Dataset.create(tmp_path / f"buffered_slice_writer_{dim}", scale=(1, 1, 1))
92-
mag_view = ds.add_layer(
93-
"color", LayerCategories.COLOR_TYPE, num_channels=3
94-
).add_mag(1)
92+
mag_view = ds.add_layer("color", COLOR_CATEGORY, num_channels=3).add_mag(1)
9593

9694
with mag_view.get_buffered_slice_writer(
9795
offset, buffer_size=5, dimension=dim
@@ -116,9 +114,7 @@ def test_buffered_slice_reader_along_different_axis(tmp_path: Path) -> None:
116114

117115
for dim in [0, 1, 2]:
118116
ds = Dataset.create(tmp_path / f"buffered_slice_reader_{dim}", scale=(1, 1, 1))
119-
mag_view = ds.add_layer(
120-
"color", LayerCategories.COLOR_TYPE, num_channels=3
121-
).add_mag(1)
117+
mag_view = ds.add_layer("color", COLOR_CATEGORY, num_channels=3).add_mag(1)
122118
mag_view.write(test_cube, offset=offset)
123119

124120
with mag_view.get_buffered_slice_reader(

0 commit comments

Comments
 (0)