Add .into_view/_mut() methods to Windows, ExactChunks, and ExactChunksMut
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Locate Windows, ExactChunks, ExactChunksMut, and the DimAdd trait from issue #570. Compare the proposed Windows::into_view implementation with the corresponding types, then add the requested immutable and mutable view methods; done means all three types support the requested conversions while preserving outer and window axes.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
This can be convenient for some use cases, such as copying windows (especially with a non-unit step between windows) into a new owned array for modification.
This would rely on the DimAdd trait from #570. For example, the implementation for Windows could be the following:
impl<'a, A, D: Dimension> Windows<'a, A, D> {
/// Returns a view such that the outer axes are the iteration axes and the
/// inner axes are the axes of the windows.
///
/// # Example
///
/// ```
/// use ndarray::{array, aview2, s};
///
/// let arr = array![
/// [0, 1, 2, 3],
/// [4, 5, 6, 7],
/// [8, 9, 10, 11],
/// ];
/// let windows = arr.windows([2, 3]).into_view();
/// assert_eq!(windows.shape(), &[2, 2, 2, 3]);
/// assert_eq!(
/// windows.slice(s![0, 0, .., ..]),
/// aview2(&[[0, 1, 2], [4, 5, 6]]),
/// );
/// assert_eq!(
/// windows.slice(s![0, 1, .., ..]),
/// aview2(&[[1, 2, 3], [5, 6, 7]]),
/// );
/// assert_eq!(
/// windows.slice(s![1, 0, .., ..]),
/// aview2(&[[4, 5, 6], [8, 9, 10]]),
/// );
/// assert_eq!(
/// windows.slice(s![1, 1, .., ..]),
/// aview2(&[[5, 6, 7], [9, 10, 11]]),
/// );
/// ```
pub fn into_view(self) -> ArrayView<'a, A, <D as DimAdd<D>>::Output> {
let base_ndim = self.base.ndim();
let out_ndim = 2 * base_ndim; // check for overflow?
let mut out_dim = <D as DimAdd<D>>::Output::zeros(out_ndim);
out_dim.slice_mut()[..base_ndim].copy_from_slice(&self.base.dim.slice());
out_dim.slice_mut()[base_ndim..].copy_from_slice(&self.window.slice());
let mut out_strides = <D as DimAdd<D>>::Output::zeros(out_ndim);
out_strides.slice_mut()[..base_ndim].copy_from_slice(&self.base.strides.slice());
out_strides.slice_mut()[base_ndim..].copy_from_slice(&self.strides.slice());
unsafe { self.base.with_strides_dim(out_strides, out_dim) }
}
}
- Ngôn ngữ chính
- Rust
- Star
- 4.3k
- Fork
- 391
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rust-ndarray/ndarray
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
rust-ndarray/ndarray#1612 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
rust-ndarray/ndarray#1617 · 1 bình luận ·
-
Stack overflow in `triu` Đang mởbug good first issue
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
rust-ndarray/ndarray#1615 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
rust-ndarray/ndarray#1610 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
rust-ndarray/ndarray#1609 ·
Tất cả issue của rust-ndarray/ndarray
Issue tương tự
-
risk:low runtime status:in-progress type:test
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
zeroclaw-labs/zeroclaw#11023 ·
-
good first issue refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
EricSpencer00/Resilient#4835 · 1 bình luận ·
-
agent:ready documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
cesarferreira/stax#890 ·
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100