Skip to content

ndarray from_iterator panics on rectangular column-major input #482

Description

@jolars

I found this while working on #480. The ndarray implementation of Array2::from_iterator does not handle column-major input correctly for rectangular matrices.

For example, from_iterator(1..=6, 2, 3, 1) should produce [[1, 3, 5], [2, 4, 6]]. The current implementation first builds a row-major array, reverses its axes, and then tries to reshape it in row-major order. For this input, the reshape fails and the method panics.

The fix is to use column-major order when reshaping the input for axis = 1. I will move that fix from #480 into a separate PR, with tests for both input orders and empty matrices, and a changelog entry.

Activity

  1. added a commit that references this issue on Oct 12, 2026
    f9a5496
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions