Skip to content

Commit b588a24

Browse files
committed
Edit docs for from_shape_vec
1 parent a7138e9 commit b588a24

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/impl_constructors.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,20 @@ impl<S, A, D> ArrayBase<S, D>
188188
///
189189
/// **Errors** if strides and dimensions can point out of bounds of `v`.<br>
190190
/// **Errors** if strides allow multiple indices to point to the same element.
191+
///
192+
/// ```
193+
/// use ndarray::prelude::*;
194+
///
195+
/// let a = OwnedArray::from_shape_vec((2, 2), vec![1., 2., 3., 4.]);
196+
/// assert!(a.is_ok());
197+
///
198+
/// let b = OwnedArray::from_shape_vec((2, 2).strides((1, 2)),
199+
/// vec![1., 2., 3., 4.]).unwrap();
200+
/// assert!(
201+
/// b == arr2(&[[1., 3.],
202+
/// [2., 4.]])
203+
/// );
204+
/// ```
191205
pub fn from_shape_vec<Sh>(shape: Sh, v: Vec<A>) -> Result<ArrayBase<S, D>, ShapeError>
192206
where Sh: Into<StrideShape<D>>,
193207
{

0 commit comments

Comments
 (0)