`ndarray::stack` changed behavior w.r.t layout between 0.15.1 and 0.15.2

Aperta
#1,070 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
rust
Ambito
data

Direzione di ricerca

Start by running the issue's demonstration program with ndarray pinned to 0.15.2 and 0.15.3, then inspect the ndarray::stack implementation and its documentation. Determine whether the layout change is intended and whether the docs specify the returned layout. Done means the behavior is clarified through a fix or documentation update, with the reproduction covered.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

docs

Before 0.15.3, stack would return an array with C-layout when given C-layout views. But with 0.15.3, this behavior changed and now we get F-layout outputs. This demonstration program will succeed if you pin ndarray to "=0.15.2" and fail if you pin to "=0.15.3":

use ndarray::{arr2, stack, Axis};

fn main() {
    // Here are some 2x3 arrays.
    let a = arr2(&[[1, 2, 3], [4, 5, 6]]);
    let b = &a * 2;
    assert_eq!(a.shape(), b.shape());
    assert_eq!(a.shape(), [2, 3]);

    // When we stack them with Axis(2), we'll get a 2x3x4 array
    // with the last dimension stored continuously.
    let c = stack(Axis(2), &[a.view(), b.view(), a.view(), b.view()]).unwrap();
    assert_eq!(c.shape(), [2, 3, 4]);
    assert!(c.is_standard_layout());
    dbg!(&c);
}

I don't see anything about the layout of stack's return value in the docs so I assumed that it would match the inputs. So even if no code behavior change is warranted, the docs should really include a note explaining that you might get a different layout than your inputs.

Lingua principale
Rust
Stelle
4.3k
Fork
391
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rust-ndarray/ndarray

Tutte le issue di rust-ndarray/ndarray

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.