Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.
This repository was archived by the owner on Sep 9, 2026. It is now read-only.

toch/np like indexig for DocumentArrayStacked #1073

Description

@JohannesMessner

PyTorch (and numpy, too) supports a rich and flexible indexing API: https://pytorch.org/cppdocs/notes/tensor_indexing.html
DocumentArrayStacked should support the same.

Concretely, we should be able to do the following:

da = DocumentArray([... for _ in range(5)]
da[0]  # index by offset; returns doc at this position
da[0:5:2]  # index by slice; returns every other doc
da[0, 1, 2]  # index by sequence of positions; returns DocumentArray with docs at these positions
da[[0, 1, 2]]  # same as above
da[[True, False, True, True, False]]  # index by boolean mask; returns DocumentArray with "True" docs
da[None]  # returns `da`, just to conform with PyTorch convention

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

DocArray v2This issue is part of the rewrite; not to be merged into main

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions