Skip to content

fix: fromArray now actually uses the provided shape parameter - #27

Merged
CodeWithKyrian merged 1 commit into
mainfrom
fix/fromarray-ignores-shape
Jun 6, 2026
Merged

CodeWithKyrian merged 1 commit into
mainfrom
fix/fromarray-ignores-shape

Conversation

@CodeWithKyrian

Copy link
Copy Markdown
Contributor

This PR fixes a bug where fromArray() silently ignored its $shape parameter.

Motivation and Context

fromArray() accepts an optional $shape parameter but delegated to array(), which always infers shape from the input data. Calling NDArray::fromArray([1, 2, 3, 4, 5, 6], [2, 3]) would create a 1D array of shape [6] instead of the requested [2, 3], with no warning or error.

What's Changed

  • fromArray() now duplicates array()'s creation logic instead of proxying to it, using the provided shape when given and only inferring from data as a fallback

Breaking Changes

None.

@CodeWithKyrian
CodeWithKyrian merged commit 2ebb7f1 into main Jun 6, 2026
14 checks passed
@CodeWithKyrian
CodeWithKyrian deleted the fix/fromarray-ignores-shape branch June 6, 2026 21:56
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.

1 participant