NumpySample¶
- class probly.representation.sample.numpy.NumpySample(array: D, sample_axis: int, weights: np.ndarray | None = None)[source]¶
Bases:
NumpyArrayLikeImplementation,Sample,GenericA sample of predictions stored in a numpy array.
- array: D¶
- astype(dtype: DTypeLike, order: Order = 'K', casting: Literal['no', 'equiv', 'safe', 'same_kind', 'unsafe'] = 'unsafe', subok: bool = True, copy: bool = True) Self[source]¶
Cast the stored array while preserving the sample axis and weights.
- copy(order: Order = 'C') Self[source]¶
Create a copy of the NumpySample.
- Returns:
A copy of the NumpySample.
- property flags: ArrayFlagsLike¶
The flags of the array.
- classmethod from_iterable(samples: Iterable[D], weights: Iterable[float] | None = None, sample_axis: SampleAxis = 'auto', dtype: DTypeLike | None = None) Self[source]¶
Create an NumpySample from a sequence of samples.
- Parameters:
samples – The predictions to create the sample from.
weights – Optional weights for the samples.
sample_axis – The dimension along which samples are organized.
dtype – Desired data type of the array.
- Returns:
The created NumpySample.
- classmethod from_sample(sample: Sample[D], sample_axis: SampleAxis = 'auto', dtype: DTypeLike | None = None) 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.
- move_sample_axis(new_sample_axis: int) NumpySample[D][source]¶
Return a new NumpySample with the sample dimension moved to new_sample_axis.
- Parameters:
new_sample_axis – The new sample dimension.
- Returns:
A new NumpySample with the sample dimension moved.
- property samples: D¶
Return an iterator over the samples.
- transpose(*axes: int | None) Self[source]¶
Return a transposed version of the NumpySample.
This method implicitly also provides full axis tracking support for - np.moveaxis - np.rollaxis Those functions call out to transpose methods for custom array types.
- Parameters:
axes – The axes to transpose.
- Returns:
A transposed version of the NumpySample.