Skip to content

Commit 96917bc

Browse files
committed
Fix so that fusion can be run more than once
1 parent 74f83af commit 96917bc

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/napari_stitcher/_stitcher_widget.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Replace code below according to your needs.
88
"""
99
from typing import TYPE_CHECKING
10-
import os, tempfile, sys
10+
import os, tempfile, sys, shutil
1111
from collections.abc import Iterable
1212

1313
import numpy as np
@@ -389,6 +389,8 @@ def run_fusion(self):
389389
mfused = msi_utils.get_msim_from_sim(fused, scale_factors=[])
390390

391391
tmp_fused_path = os.path.join(self.tmpdir.name, 'fused_%s.zarr' %ch)
392+
if os.path.exists(tmp_fused_path):
393+
shutil.rmtree(tmp_fused_path)
392394

393395
with _utils.TemporarilyDisabledWidgets(self.all_widgets),\
394396
_utils.VisibleActivityDock(self.viewer),\

src/napari_stitcher/_tests/test_stitcher_widget.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ def test_fusion_without_registration(make_napari_viewer):
221221
stitcher_widget.run_fusion()
222222
assert len(viewer.layers) == 3
223223

224+
#check that fusion can also be run twice
225+
stitcher_widget.run_fusion()
226+
224227

225228
def test_vanilla_layers_2D_no_time(make_napari_viewer):
226229

0 commit comments

Comments
 (0)