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

Aberta
#1,609 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
72/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Pouca atividade
Stack de tecnologia
rust
Domínio
data

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Rust
Estrelas
4.3k
Forks
391
Métricas de merge de PRs
Nenhum PR com merge em 30d

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de rust-ndarray/ndarray

Todas as issues de rust-ndarray/ndarray

Issues semelhantes

Mais issues de Rust

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.