Empty Array lead to "The strides must not allow any element to be referenced by two different indices"

Aperta
#1,609 0 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
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
rust
Ambito
data

Direzione di ricerca

Start with the dim_stride_overlap function identified in the issue and reproduce both ArrayView2::from_shape_ptr examples, including the (1, 0) shape with (0, 0) strides. Done means empty arrays with either zero dimension are accepted consistently, while non-empty overlapping strides continue to be rejected.

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

Descrizione

I tried to create an empty array with the following command:

let shape = (1, 0).strides((0, 0));
let ptr = std::ptr::dangling::<f64>();
unsafe { ArrayView2::from_shape_ptr(shape, ptr) }

It fails with "The strides must not allow any element to be referenced by two different indices".

But the slightly different code works:

let shape = (0, 1).strides((0, 0));
let ptr = std::ptr::dangling::<f64>();
unsafe { ArrayView2::from_shape_ptr(shape, ptr) }

My expectation would be that both variants work fine.

I think the bug is inside dim_stride_overlap, which fails before the first 0 dimension is found and therefore recognises that the complete array is empty.

By the way, I use (0, 0) strides, since ndarray does the same for empty array e.g. created via zeros function.

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.