Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bioimageio/core/_resource_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ def evaluate_mismatched_elements(

rtol_value = rtol * abs(expected_np)
abs_diff = abs(actual_np - expected_np)
mismatched = abs_diff > atol + rtol_value
mismatched = ~np.isclose(actual_np, expected_np, rtol=rtol, atol=atol)
mismatched_elements = mismatched.sum().item()

mismatched_ppm = mismatched_elements / expected_np.size * 1e6
Expand Down
16 changes: 16 additions & 0 deletions tests/test_resource_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest

from bioimageio.core import __version__
from bioimageio.core.tensor import Tensor
from bioimageio.spec import InvalidDescr, ValidationContext


Expand Down Expand Up @@ -80,3 +81,18 @@ def test_failed_reproducibility(unet2d_nuclei_broad_model: str, tmp_path: str):
summary = test_model(model)

assert summary.status == "valid-format"


def test_reproducibility_rejects_nan_output():
from bioimageio.core._resource_tests import evaluate_mismatched_elements

actual = Tensor(np.full((2,), np.nan), dims=("x",))
expected = Tensor(np.ones((2,)), dims=("x",))

mismatched_ppm, msg, error_msg = evaluate_mismatched_elements(
actual, expected, rtol=1e-3, atol=1e-3, name="output"
)

assert error_msg is None
assert mismatched_ppm == 1_000_000
assert "2 of 2 elements disagree" in msg
Loading