Skip to content

Commit 82ea473

Browse files
Raise proper validation error for wrong reference tensor names
1 parent 0780b53 commit 82ea473

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

bioimageio/core/resource_tests.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ def _validate_output_shape(shape: Tuple[int, ...], shape_spec, input_shapes) ->
6363
if isinstance(shape_spec, list):
6464
return shape == tuple(shape_spec)
6565
elif isinstance(shape_spec, ImplicitOutputShape):
66-
ipt_shape = numpy.array(input_shapes[shape_spec.reference_tensor])
66+
ref_tensor = shape_spec.reference_tensor
67+
if ref_tensor not in input_shapes:
68+
raise ValidationError(f"The reference tensor name {ref_tensor} is not in {input_shapes}")
69+
ipt_shape = numpy.array(input_shapes[ref_tensor])
6770
scale = numpy.array(shape_spec.scale)
6871
offset = numpy.array(shape_spec.offset)
6972
exp_shape = numpy.round_(ipt_shape * scale) + 2 * offset

0 commit comments

Comments
 (0)