Skip to content

feat: add Dimension::from_slice#1608

Open
SomeB1oody wants to merge 1 commit into
rust-ndarray:masterfrom
SomeB1oody:dimension-from-slice
Open

feat: add Dimension::from_slice#1608
SomeB1oody wants to merge 1 commit into
rust-ndarray:masterfrom
SomeB1oody:dimension-from-slice

Conversation

@SomeB1oody

Copy link
Copy Markdown

Closes #1330

Summary

Add Dimension::from_slice(&[Ix]) -> Option<Self>, which returns None when Self::NDIM.is_some_and(|n| n != ix.len()) (the fixed-size types require an exact length match and IxDyn accepts any length)

from_dimension now uses Self::from_slice(d.slice())

Tests

Added from_slice to tests/dimension.rs. cargo test passes.

Add a public `from_slice` that returns `None` when the slice length does not match the type's dimensionality (`IxDyn` accepts any length). Now `from_dimension` uses `from_slice`
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.

add associated constructor to Dimension trait

1 participant