CADETProcess.dataStructure.parameter.Sized

CADETProcess.dataStructure.parameter.Sized#

class CADETProcess.dataStructure.parameter.Sized(*args: Any, size: int | tuple, **kwargs: Any)[source]#

Bases: ParameterBase

Descriptor for parameters with size that potentially depends on instance attributes.

Attributes:
sizetuple

Expected size or dimensions of the parameter. Individual elements can be either integers or strings indicating other instance parameters that influence the size.

Methods

is_independent

Determine whether the size is independent of other parameters.

get_size(value) -> int

Calculates the size of the given value. Override for custom behavior.

get_expected_size(instance) -> int

Computes the expected size based on the instance’s other attributes.

check_size(instance, value)

Validates that the provided value’s size matches the expected size.

check_size(instance: Any, value: Any) None[source]#

Validate that the provided value’s size matches the expected size.

Parameters:
instanceobject

The instance associated with the parameter.

valueAny

The value whose size needs to be validated.

Raises:
ValueError

If the value’s size does not match the expected size.

get_expected_size(instance: Any) int[source]#

Compute the expected size based on the instance’s other attributes.

Parameters:
instanceobject

The instance whose attributes determine the expected size.

Returns:
int

Computed expected size based on instance attributes.

Raises:
ValueError

If an attribute, on which the size depends, is not set.

get_size(value: Any) int | tuple[int, ...][source]#

Determine the size of the provided value.

Parameters:
valueAny

The value for which the size needs to be calculated.

Returns:
int | tuple[int, …]

Size of the value.

property is_independent: bool#

Determine whether the size is independent of other parameters.

Returns:
bool

True if the size is independent, False if it depends on other instance attributes.