plaid.containers.features.scalars

Module for implementing collections of features within a Sample.

Classes

SampleScalars

A container for scalar features within a Sample.

Module Contents

class SampleScalars(scalars: dict[str, plaid.types.Scalar] | None)[source]

A container for scalar features within a Sample.

Provides dict-like operations for adding, retrieving, and removing scalars.

Names must be unique and may not contain the character /.

Parameters:

scalars (dict[str, Scalar], optional) – a dict containing the pairs of (name, value) for each scalar in the Sample.

data: dict[str, plaid.types.Scalar][source]
add(name: str, value: plaid.types.Scalar) None[source]

Add a scalar value to a dictionary.

Parameters:
  • name (str) – The name of the scalar value.

  • value (Scalar) – The scalar value to add or update in the dictionary.

remove(name: str) plaid.types.Scalar[source]

Delete a scalar value from the dictionary.

Parameters:

name (str) – The name of the scalar value to be deleted.

Raises:

KeyError – Raised when there is no scalar / there is no scalar with the provided name.

Returns:

The value of the deleted scalar.

Return type:

Scalar

get(name: str) plaid.types.Scalar | None[source]

Retrieve a scalar value associated with the given name.

Parameters:

name (str) – The name of the scalar value to retrieve.

Returns:

The scalar value associated with the given name, or None if the name is not found.

Return type:

Scalar or None

get_names() list[str][source]

Get a set of scalar names available in the object.

Returns:

A set containing the names of the available scalars.

Return type:

list[str]