Skip to content

Commit a16756f

Browse files
committed
Update result shape merging logic in dst_n_to_1 function to skip the first source object when keeping results
1 parent c22bff3 commit a16756f

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

cdl/tests/features/common/resultshapes_app_test.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,16 @@ def __check_resultshapes_merge(
4949
obj1: Original object
5050
obj2: Merged object
5151
"""
52-
for rs1, rs2 in zip(obj1.iterate_resultshapes(), obj2.iterate_resultshapes()):
52+
rsl1, rsl2 = list(obj1.iterate_resultshapes()), list(obj2.iterate_resultshapes())
53+
assert len(rsl2) == len(rsl1), (
54+
"Merged object the same number of result shapes as original object, "
55+
"but expected twice the number of result shapes for each type."
56+
)
57+
for rs1, rs2 in zip(rsl1, rsl2):
58+
assert rs1.array.shape[0] * 2 == rs2.array.shape[0], (
59+
f"Result shape array length mismatch: {rs1.array.shape[0]} * 2 != "
60+
f"{rs2.array.shape[0]}"
61+
)
5362
assert np.all(np.vstack([rs1.array, rs1.array])[:, 1:] == rs2.array[:, 1:])
5463

5564

sigima_/computation/base.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,11 @@ def dst_n_to_1(
251251
dst.roi = None
252252
if not options.keep_results.get():
253253
dst.delete_results() # Remove any previous results
254-
for src_obj in src_list:
255-
if options.keep_results.get():
254+
for index, src_obj in enumerate(src_list):
255+
if options.keep_results.get() and index > 0:
256+
# If we keep results, we need to merge the result shapes.
257+
# We skip the first object, as it is already copied
258+
# to the destination object.
256259
dst.update_resultshapes_from(src_obj)
257260
if src_obj.roi is not None:
258261
if dst.roi is None:

0 commit comments

Comments
 (0)