Repository navigation
Bugfix: toArray method for Tensor2 and Tensor3 to handle axes of extent 0 correctly - #184
Merged
Merged
Conversation
marcelluethi
requested review from
benikm91
and
a balanced review from Copilot
November 17, 2026 19:58
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the zero-length-axis tensor conversion changes.
No open issues 🎉
What changed in this PR
Fixes Tensor2.toArray and Tensor3.toArray so tensors with zero-length axes produce correctly shaped nested arrays.
Changes:
- Replaces grouping with shape-driven array construction, avoiding zero-sized groups and preserving empty inner dimensions.
- Adds regression tests for zero extent on each axis of 2D and 3D tensors.
| File | Description |
|---|---|
core/src/test/scala/dimwit/tensor/ToArraySuite.scala |
Adds zero-extent conversion tests for every axis. |
core/src/main/scala/dimwit/tensor/tensorops/Tensor3Extensions.scala |
Constructs 3D arrays using explicit axis extents and flat-data slices. |
core/src/main/scala/dimwit/tensor/tensorops/Tensor2Extensions.scala |
Constructs 2D arrays using explicit row and column extents. |
Review effort: Balanced
benikm91
approved these changes
Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.