Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Add .into_view/_mut() methods to Windows, ExactChunks, and ExactChunksMut

オープン
#920 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
rust
領域
data

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

enhancement help wanted

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) }
    }
}
主要言語
Rust
スター
4.3k
フォーク
391
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rust-ndarray/ndarray のほかの issue

rust-ndarray/ndarray の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。