Skip to content

Commit

Permalink
better broken slice handling
Browse files Browse the repository at this point in the history
  • Loading branch information
clbarnes committed Jul 14, 2023
1 parent e9b4507 commit 088ddf1
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions pymaid/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ def __init__(
else:
self.session = session

brok_sl = {int(k): int(k) + v for k, v in self.stack_info.broken_slices.items()}
self.broken_slices = dict()
for k, v in brok_sl.items():
while v in brok_sl:
v = brok_sl[v]
self.broken_slices[k] = v

order = self.stack_info.orientation.full_orientation(reverse=True)
self.metadata_bytes = json.dumps(
{
Expand Down Expand Up @@ -254,11 +261,7 @@ def __setitem__(self, __key, __value) -> None:
raise NotImplementedError()

def _resolve_broken_slices(self, slice_idx: int) -> int:
while True:
incr = self.stack_info.broken_slices.get(slice_idx)
if incr is None:
return slice_idx
slice_idx += incr
return self.broken_slices.get(slice_idx, slice_idx)

def __getitem__(self, key):
last = key.split("/")[-1]
Expand Down Expand Up @@ -337,8 +340,11 @@ class TileStore5(JpegStore):


tile_stores: dict[int, Type[JpegStore]] = {
t.tile_source_type: t for t in [
TileStore1, TileStore4, TileStore5,
t.tile_source_type: t
for t in [
TileStore1,
TileStore4,
TileStore5,
# TileStore10
]
}
Expand Down

0 comments on commit 088ddf1

Please sign in to comment.