Accept owned arrays in `concatenate` and `stack`

Abierto
#1,591 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
45/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
rust
Área
data

Línea de trabajo

Start by reading the current concatenate and stack entry points and their signatures. Check how they accept views, how owned arrays would fit, and what happens for an empty slice. Done means the proposed API works for owned arrays and views without leaving the documented inference concern unresolved.

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

Descripción

breaking-change enhancement

It would be convenient to be able to call concatenate or stack with a slice of owned arrays or array views, rather than just views currently.

So for concatenate, this:

let arrays = vec![a, b, c]; // more realistically, this would be returned by a function
let arrays = arrays.iter().map(|a| a.view()).collect::<Vec<_>>();
let res = ndarray::concatenate(Axis(2), &arrays);

would become:

let arrays = vec![a, b, c];
let res = ndarray::concatenate(Axis(2), &arrays);

This could be done by changing the signature of concatenate to the following, which would allow either views or owned arrays:

-pub fn concatenate<A, D>(axis: Axis, arrays: &[ArrayView<A, D>]) -> Result<Array<A, D>, ShapeError>
+pub fn concatenate<S, D, A>(axis: Axis, arrays: &[ArrayBase<S, D, A>]) -> Result<Array<A, D>, ShapeError>
 where
+    S: Data<Elem = A>,
     A: Clone,
     D: RemoveAxis,
 {

This is technically a breaking API change though, at least in the niche case of passing an empty slice as a parameter (which causes a type inference error). Before I open an unsolicited PR, would there be interest in this change?

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.