Is indexing with a variable number of indices supported?

Offen
#865 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
30/100
Issue-Typ
Feature
Klarheit
Muss geklärt werden
Aktivitätsstatus
Veraltet
Tech-Stack
rust
Bereich
data

Rechercherichtung

Start by reading ArrayBase::slice() and the s! macro, then compare the requested variable-index behavior with the linked NumPy example. A completed investigation should establish whether ndarray supports the operation, identify a documented workaround or define what support would need to add, and update the linked Stack Overflow answer.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

I'd like to index a tensor along all but the last axis, getting as a result a 1d view of the innermost axis. I thought I'd be able to use ArrayBase::slice() for this, but I need create the index with the s! macro and I can't figure out how to do that with a variable number of indices (such as if the user provides the coordinates of the spatial dimensions in a tensor, and I want to slice on that leaving a 1d view of the feature dimension where the feature dimension is the innermost dimension).

I asked a stack overflow question for this here, if it is indeed supported then perhaps we could add a stack overflow answer there? If not, when would support be added and is there a workaround in the meantime?

The equivalent numpy feature, which is actually slightly more general than my specific use case since I only need a view on the innermost axis, is here

Vorherrschende Sprache
Rust
Sterne
4.3k
Forks
391
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus rust-ndarray/ndarray

Alle Issues in rust-ndarray/ndarray

Ähnliche Issues

Weitere Issues zu Rust

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.