jina.types.arrays.mixins.sample module

class jina.types.arrays.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

DocumentArray

Returns

A sampled list of Document represented as DocumentArray.

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

DocumentArray

Returns

The shuffled list of Document represented as DocumentArray.