'into_shape()' incompatible memory layout error

Abierto
#1,172 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
rust
Área
data

Línea de trabajo

Start with the reproducer in src/env.rs around the reported line and run env::test::ndarray_into_shape_test. Compare the memory layouts of the contiguous array and the sliced view before into_shape((3, 1)). Done means explaining why the same Rust type behaves differently and resolving or clearly documenting the incompatible-layout behavior.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

       let d = aview1(&[1., 2., 3., 4.]);

        let d = d.into_shape((2, 2)).unwrap();
        println!("d shape {:?}", &d.shape());

        let a = array![
            [110., 120., 130., 140.,],
            [210., 220., 230., 240.,],
            [310., 320., 330., 340.,],
        ];

        let a = a.slice(s![.., 1]);

        let a = a.into_shape((3, 1)).unwrap();
        println!("a {:?}", &a);
        println!("a shape {:?}", &a.shape());

image

running 1 test
d shape [2, 2]
thread 'env::test::ndarray_into_shape_test' panicked at 'called `Result::unwrap()` on an `Err` value: ShapeError/IncompatibleLayout: incompatible memory layout', src\env.rs:483:38
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
test env::test::ndarray_into_shape_test ... FAILED

Both d and a is same type but panic occurs.
Is there any reason why they behave differently?
(slice_mut, slice_move, clone() also shows same error)

Lenguaje dominante
Rust
Estrellas
4.3k
Forks
391
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de rust-ndarray/ndarray

Todos los issues de rust-ndarray/ndarray

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.