Skip to content

Fix num_channels_per_class=1 behavior in structure_model_output#196

Merged
rhoadesScholar merged 2 commits intomulti_channel_writingfrom
copilot/sub-pr-188
Feb 20, 2026
Merged

Fix num_channels_per_class=1 behavior in structure_model_output#196
rhoadesScholar merged 2 commits intomulti_channel_writingfrom
copilot/sub-pr-188

Conversation

Copy link
Contributor

Copilot AI commented Feb 20, 2026

The structure_model_output function documented that num_channels_per_class only applies when > 1, but treated 1 as "split into per-class dict" instead of returning a tensor like None does.

Changes

  • Modified conditional checks: Changed if num_channels_per_class is not None: to if num_channels_per_class is not None and num_channels_per_class > 1: in both dict-input and tensor-input branches
  • Updated docstring: Clarified that both None and 1 mean one channel per class
  • Added test coverage: Two test cases verifying num_channels_per_class=1 returns tensors, not dicts

Before/After

# Before: num_channels_per_class=1 incorrectly split into dict
outputs = torch.zeros(2, 3, 8, 8)  # 3 classes, 1 ch each
result = structure_model_output(outputs, classes, num_channels_per_class=1)
# Returns: {"output": {"class1": tensor, "class2": tensor, "class3": tensor}}

# After: num_channels_per_class=1 behaves like None
result = structure_model_output(outputs, classes, num_channels_per_class=1)
# Returns: {"output": tensor}  # Same as num_channels_per_class=None

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copy link
Contributor Author

Copilot AI commented Feb 20, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • invalid-url-that-does-not-exist-12345.com
    • Triggering command: /usr/bin/python python -m pytest tests/test_utils.py -v (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Update prediction handling and output validation based on feedback Fix num_channels_per_class=1 behavior in structure_model_output Feb 20, 2026
Copilot AI requested a review from rhoadesScholar February 20, 2026 20:43
@rhoadesScholar rhoadesScholar marked this pull request as ready for review February 20, 2026 21:10
@rhoadesScholar rhoadesScholar merged commit 248caf4 into multi_channel_writing Feb 20, 2026
7 checks passed
@rhoadesScholar rhoadesScholar deleted the copilot/sub-pr-188 branch February 20, 2026 21:15
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