Skip to content

Comments

Add test coverage for multi-channel writing and fix bounding box bug#57

Merged
rhoadesScholar merged 8 commits intomulti_channel_writingfrom
copilot/sub-pr-56
Feb 18, 2026
Merged

Add test coverage for multi-channel writing and fix bounding box bug#57
rhoadesScholar merged 8 commits intomulti_channel_writingfrom
copilot/sub-pr-56

Conversation

Copy link
Contributor

Copilot AI commented Feb 18, 2026

Codecov reported 33% patch coverage with 6 uncovered lines in the multi-channel writing feature (n_channels parameter and channel axis handling).

Changes

  • Added tests for n_channels parameter in CellMapDatasetWriter covering automatic channel axis addition and deduplication when axis already exists
  • Added tests for channel axis detection in ImageWriter covering automatic detection from shape, explicit specification, and no-op when unnecessary
  • Added tests for CellMapDataset.empty() verifying has_data and _sampling_box_shape initialization
  • Fixed bug in ImageWriter.__init__: bounding_box now correctly includes channel dimension {"c": [0, n_channels]} when channel axis is detected or specified
  • Fixed scale assignment: prepended channel axis now uses 1.0 (unitless) instead of copying first spatial scale

Example

# Channel axis automatically detected and bounding_box updated
writer = ImageWriter(
    path="output.zarr",
    target_class="predictions",
    scale=(4.0, 4.0, 4.0),
    write_voxel_shape=(3, 32, 32, 32),  # 4D: channels + spatial
    axis_order="zyx",                    # 3D spatial only
    bounding_box={"z": [0, 256], "y": [0, 256], "x": [0, 256]},
)
# Now: axes="czyx", bounding_box includes "c": [0, 3]

Coverage Impact

  • dataset_writer.py: 33% → 57%
  • image_writer.py: 47% → 75%
  • dataset.py: 29% → 76%

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…ling

Co-authored-by: rhoadesScholar <37990507+rhoadesScholar@users.noreply.github.com>
Copilot AI changed the title [WIP] Add multi channel writing feature Add test coverage for multi-channel writing and fix bounding box bug Feb 18, 2026
Copilot AI mentioned this pull request Feb 18, 2026
Copilot AI requested a review from rhoadesScholar February 18, 2026 15:47
@rhoadesScholar rhoadesScholar marked this pull request as ready for review February 18, 2026 15:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds test coverage for multi-channel writing features and fixes two critical bugs in ImageWriter: incorrect bounding_box handling for channel dimensions and incorrect scale assignment for channel axes. The changes improve code coverage from 33% to 57% for dataset_writer.py, 47% to 75% for image_writer.py, and 29% to 76% for dataset.py.

Changes:

  • Added tests for automatic channel axis detection and deduplication in ImageWriter and CellMapDatasetWriter
  • Added tests for CellMapDataset.empty() method initialization
  • Fixed ImageWriter to correctly add channel dimension to bounding_box when channel axis is detected
  • Fixed scale assignment to use 1.0 (unitless) for channel axis instead of copying first spatial scale

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
tests/test_empty_image_writer.py Added three tests for channel axis detection scenarios: automatic detection, explicit specification, and no-op when dimensions match
tests/test_dataset_writer.py Added two tests for n_channels parameter: automatic channel axis addition and deduplication when axis already exists
tests/test_cellmap_dataset.py Added two tests verifying CellMapDataset.empty() correctly initializes has_data and _sampling_box_shape
src/cellmap_data/image_writer.py Fixed bounding_box to include channel dimension and scale to use 1.0 for channel axis; added tracking variable for channel axis addition

@codecov
Copy link

codecov bot commented Feb 18, 2026

Codecov Report

❌ Patch coverage is 11.86441% with 52 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.77%. Comparing base (42f2cec) to head (25aa8a4).
⚠️ Report is 9 commits behind head on multi_channel_writing.

Files with missing lines Patch % Lines
src/cellmap_data/utils/view.py 0.00% 51 Missing ⚠️
src/cellmap_data/image_writer.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@                    Coverage Diff                    @@
##           multi_channel_writing      #57      +/-   ##
=========================================================
+ Coverage                  60.48%   68.77%   +8.29%     
=========================================================
  Files                         27       27              
  Lines                       2528     2527       -1     
=========================================================
+ Hits                        1529     1738     +209     
+ Misses                       999      789     -210     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rhoadesScholar rhoadesScholar merged commit 16d1f97 into multi_channel_writing Feb 18, 2026
11 of 12 checks passed
@rhoadesScholar rhoadesScholar deleted the copilot/sub-pr-56 branch February 18, 2026 21:35
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