docarray.array.mixins.sample module#
- class docarray.array.mixins.sample.SampleMixin[source]#
Bases:
object
A mixin that provides search functionality to DocumentArrays
- sample(k, seed=None)[source]#
random sample k elements from
DocumentArray
without replacement.- Parameters:
k (
int
) – Number of elements to sample from the document array.seed (
Optional
[int
]) – initialize the random number generator, by default is None. If set will save the state of the random function to produce certain outputs.
- Return type:
- Returns:
A sampled list of
Document
represented asDocumentArray
.
- shuffle(seed=None)[source]#
Randomly shuffle documents within the
DocumentArray
.- Parameters:
seed (
Optional
[int
]) – initialize the random number generator, by default is None. If set will save the state of the random function to produce certain outputs.- Return type:
- Returns:
The shuffled list of
Document
represented asDocumentArray
.