FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: add `Dimension::from_slice` by SomeB1oody · Pull Request #1608 · rust-ndarray/ndarray · GitHub

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

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`
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add associated constructor to Dimension trait

1 participant


Back | FazBrowse Home | New Git URL