ListSample¶
- class probly.representation.sample.ListSample(samples: Iterable[T], weights: Iterable[float] | None = None)[source]¶
Bases:
list[T],Sample,GenericA sample of predictions stored in a list.
- append(object, /)¶
Append object to the end of the list.
- clear()¶
Remove all items from list.
- concat(other: Sample[T]) Self[source]¶
Creates a new sample by concatenating another sample to this sample.
- copy()¶
Return a shallow copy of the list.
- count(value, /)¶
Return number of occurrences of value.
- extend(iterable, /)¶
Extend list by appending elements from the iterable.
- classmethod from_iterable(samples: Iterable[T], weights: Iterable[float] | None = None, *, sample_axis: SampleAxis = 'auto') Self[source]¶
Create a ListSample from a sequence of samples.
- Parameters:
samples – The predictions to create the sample from.
weights – The (optional) weights for each sample.
sample_axis – The axis along which samples are organized.
kwargs – Parameters for sample creation.
- Returns:
The created ListSample.
- classmethod from_sample(sample: Sample[T], *, sample_axis: SampleAxis = 'auto') Self[source]¶
Create a new Sample from an existing Sample.
- Parameters:
sample – The sample to create the new sample from.
sample_axis – The dimension along which samples are organized.
- Returns:
The created Sample.
- index(value, start=0, stop=9223372036854775807, /)¶
Return first index of value.
Raises ValueError if the value is not present.
- insert(index, object, /)¶
Insert object before index.
- pop(index=-1, /)¶
Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
- remove(value, /)¶
Remove first occurrence of value.
Raises ValueError if the value is not present.
- reverse()¶
Reverse IN PLACE.
- property samples: Sequence[T]¶
Return an iterator over the samples.
- sort(*, key=None, reverse=False)¶
Sort the list in ascending order and return None.
The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).
If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.
The reverse flag can be set to sort in descending order.