Skip to content

Conversation

@d-chambers
Copy link
Contributor

@d-chambers d-chambers commented Oct 13, 2025

Description

This PR adds an error message to Patch.transpose raised when one of the dimensions is not found in the patch. It also improves the testing of the transpose function.

closes #570.

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes.
  • documented the new feature with docstrings and/or appropriate doc page.
  • included tests. See testing guidelines.
  • added the "ready_for_review" tag once the PR is ready to be reviewed.

Summary by CodeRabbit

  • Bug Fixes

    • Improved transpose validation: ignores ellipsis in provided dimensions and raises a clear error when unknown dimensions are supplied, including a list of valid options. Standard transpose behavior is unchanged.
  • Tests

    • Expanded test coverage for transpose across multiple dimensions, permutations, and ellipsis handling, ensuring shapes and data integrity are correct.
    • Removed an outdated transpose test to streamline the suite.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 13, 2025

Walkthrough

Adds dimension validation to Patch.transpose in dascore/proc/coords.py, filtering ellipsis and raising ParameterError for invalid dims. Test suite updated: removes an old basic transpose test and adds extensive transpose tests covering invalid dims, permutations, ellipsis handling, and data integrity.

Changes

Cohort / File(s) Summary
Coords transpose validation
dascore/proc/coords.py
Validates transpose dims by removing ellipsis and ensuring all dims exist; raises ParameterError listing invalid and valid dims; otherwise proceeds with existing transpose logic.
Proc tests update
tests/test_proc/test_basic.py, tests/test_proc/test_proc_coords.py
Removes legacy transpose test; adds comprehensive tests for invalid dimensions, various permutations (including 5D), ellipsis handling, and data integrity of transposed patches.

Possibly related issues

Suggested labels

bug, proc, patch

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly and accurately captures the primary change of adding an error message for missing dimensions in Patch.transpose without extraneous detail.
Description Check ✅ Passed The description follows the repository template by including a clear “## Description” section detailing the change, referencing the issue number with “closes #570,” and providing a “## Checklist” with all relevant items ticked.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch transpose_error_message

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9d6b3ae and 2a47e7c.

📒 Files selected for processing (3)
  • dascore/proc/coords.py (1 hunks)
  • tests/test_proc/test_basic.py (0 hunks)
  • tests/test_proc/test_proc_coords.py (1 hunks)
💤 Files with no reviewable changes (1)
  • tests/test_proc/test_basic.py
🧰 Additional context used
🧬 Code graph analysis (2)
dascore/proc/coords.py (2)
dascore/core/patch.py (1)
  • dims (212-226)
dascore/exceptions.py (1)
  • ParameterError (26-27)
tests/test_proc/test_proc_coords.py (3)
dascore/core/patch.py (4)
  • dims (212-226)
  • data (272-283)
  • coords (255-269)
  • Patch (28-511)
dascore/core/coordmanager.py (2)
  • transpose (861-888)
  • sort (349-423)
dascore/proc/coords.py (1)
  • transpose (584-623)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (18)
  • GitHub Check: test_code_min_deps (ubuntu-latest, 3.13)
  • GitHub Check: test_code_min_deps (ubuntu-latest, 3.12)
  • GitHub Check: test_code_min_deps (windows-latest, 3.13)
  • GitHub Check: test_code_min_deps (windows-latest, 3.12)
  • GitHub Check: test_code_min_deps (macos-latest, 3.13)
  • GitHub Check: test_code_min_deps (macos-latest, 3.12)
  • GitHub Check: test_code (windows-latest, 3.11)
  • GitHub Check: test_code (windows-latest, 3.13)
  • GitHub Check: test_code (macos-latest, 3.10)
  • GitHub Check: test_code (ubuntu-latest, 3.11)
  • GitHub Check: test_code (windows-latest, 3.10)
  • GitHub Check: test_code (windows-latest, 3.12)
  • GitHub Check: test_code (macos-latest, 3.11)
  • GitHub Check: test_code (ubuntu-latest, 3.13)
  • GitHub Check: test_code (macos-latest, 3.12)
  • GitHub Check: test_code (ubuntu-latest, 3.10)
  • GitHub Check: test_code (ubuntu-latest, 3.12)
  • GitHub Check: Run benchmarks
🔇 Additional comments (2)
dascore/proc/coords.py (1)

611-618: LGTM! Clear validation with helpful error message.

The dimension validation logic correctly:

  • Filters out ellipsis before validation (since it's a valid placeholder)
  • Checks remaining dimensions against the patch's dimensions
  • Raises ParameterError with a clear message listing both invalid and valid dimensions

The error message format is consistent with the select function's pattern (lines 506-512), which provides a good user experience.

tests/test_proc/test_proc_coords.py (1)

808-894: LGTM! Comprehensive test coverage for transpose functionality.

The new test suite thoroughly validates the transpose function:

  • Error handling: Tests for both single and multiple invalid dimensions with appropriate error message checks
  • Basic functionality: Tests valid transpose operations including no-args default behavior
  • Complex scenarios: The patch_5d fixture enables testing of various permutations on higher-dimensional data (complete reversal, moving dimensions, swapping, arbitrary permutations)
  • Special syntax: Tests ellipsis handling for partial dimension specification
  • Data integrity: Validates that transpose preserves data values (total size and sorted equality)

The test structure is clear, well-organized, and provides excellent coverage for the new validation logic and existing transpose behavior.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai bot added bug Something isn't working patch related to Patch class proc Related to processing module labels Oct 13, 2025
@codecov
Copy link

codecov bot commented Oct 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.92%. Comparing base (9d6b3ae) to head (2a47e7c).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #573   +/-   ##
=======================================
  Coverage   99.92%   99.92%           
=======================================
  Files         128      128           
  Lines       10767    10773    +6     
=======================================
+ Hits        10759    10765    +6     
  Misses          8        8           
Flag Coverage Δ
unittests 99.92% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 13, 2025

CodSpeed Performance Report

Merging #573 will not alter performance

Comparing transpose_error_message (2a47e7c) with master (9d6b3ae)

Summary

✅ 54 untouched

@d-chambers d-chambers merged commit f2da091 into master Oct 13, 2025
26 checks passed
@d-chambers d-chambers deleted the transpose_error_message branch October 13, 2025 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working patch related to Patch class proc Related to processing module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better error message for transpose of missing dims

2 participants