Skip to content

Commit 6e1c9e1

Browse files
authored
Make scene_id assignment result in consistent names (#25)
1 parent cbd299e commit 6e1c9e1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

dash_slicer/slicer.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
from .utils import img_array_to_uri, get_thumbnail_size, shape3d_to_size2d
88

99

10+
_assigned_scene_ids = {} # id(volume) -> str
11+
12+
1013
class VolumeSlicer:
1114
"""A slicer to show 3D image data in Dash.
1215
@@ -87,7 +90,8 @@ def __init__(
8790

8891
# Check and store scene id, and generate
8992
if scene_id is None:
90-
scene_id = "volume_" + hex(id(volume))[2:]
93+
n = len(_assigned_scene_ids)
94+
scene_id = _assigned_scene_ids.setdefault(id(volume), f"vol{n}")
9195
elif not isinstance(scene_id, str):
9296
raise TypeError("scene_id must be a string")
9397
self._scene_id = scene_id

0 commit comments

Comments
 (0)