docarray.array.mixins.sample module#
- class docarray.array.mixins.sample.SampleMixin[source]#
Bases:
objectA mixin that provides search functionality to DocumentArrays
- sample(k, seed=None)[source]#
random sample k elements from
DocumentArraywithout 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
Documentrepresented 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
Documentrepresented asDocumentArray.