Skip to content

Add RankSEG post-transform tests Ver.2#2

Merged
ZixunWang merged 1 commit into
8857-rankseg-as-optional-asdiscretefrom
8857-rankseg-test
Jun 7, 2026
Merged

Add RankSEG post-transform tests Ver.2#2
ZixunWang merged 1 commit into
8857-rankseg-as-optional-asdiscretefrom
8857-rankseg-test

Conversation

@Leev1s

@Leev1s Leev1s commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Test strategy

tests/transforms/test_as_discrete.py and tests/transforms/test_as_discreted.py are part of MONAI's minimum test suite, but rankseg is an optional dependency installed in the full/development environment. The tests therefore separate minimum-safe API coverage from the real optional dependency path.

Minimum dependency tests still cover:

  • existing AsDiscrete / AsDiscreted behavior;
  • explicit rankseg=False with argmax=True;
  • rankseg=True plus argmax=True incompatibility;
  • missing optional dependency behavior via OptionalImportError.

Full/development tests additionally run a real RankSEG value/shape case. The chosen input is a two-class probability map.

img = [
    [[0.45, 0.55]],  # class 0
    [[0.55, 0.45]],  # class 1
]

For this input, argmax=True produces [[[1.0, 0.0]]], while the default RankSEG decoder produces [[1.0, 1.0]].

AsDiscreted full/development tests also cover dictionary forwarding, including the per-key rankseg=[True, False] case.

The real RankSEG cases are only added when the optional package is available, so minimum tests do not report dependency-related skips and continue to exercise the rest of the file.

Validation

Targeted tests passed locally:

uv run pytest tests/transforms/test_as_discrete.py tests/transforms/test_as_discreted.py
uv run python -m unittest tests.transforms.test_as_discrete tests.transforms.test_as_discreted

Results:

  • pytest: 53 passed
  • unittest: 53 passed

@Leev1s Leev1s force-pushed the 8857-rankseg-test branch from 70987c0 to a47c8c3 Compare June 7, 2026 09:03
@Leev1s Leev1s marked this pull request as ready for review June 7, 2026 09:05
@ZixunWang ZixunWang merged commit 68532fc into 8857-rankseg-as-optional-asdiscrete Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants