corelay.base

A module that contains core CoRelAy classes, such as Param.

Classes

Param

A single parameter slot, which can be used to parameterize implementations of Processor.

class corelay.base.Param[source]

Bases: Slot

A single parameter slot, which can be used to parameterize implementations of Processor. The instances of Param in a Processor implementation are tracked by a Tracker.

__init__(dtype: type[Any] | tuple[type[Any], ...], default: Any = None, mandatory: bool = False, positional: bool = False, identifier: bool = False) None[source]

Initializes a new Param instance, and configures its type and default value of the parameter.

Parameters:
  • dtype (type[Any] | tuple[type[Any], ...]) – The allowed type(s) of the parameter. This can be a single type or a tuple of multiple type instances.

  • default (Any) – The default value of the parameter. This must be an instance of one of the types specified in the dtype parameter.

  • mandatory (bool) – A value indicating whether this parameter is mandatory. If True, the default value will be removed. Defaults to False.

  • positional (bool) – A value indicating whether this parameter will have to be passed as a positional argument to Processor.__init__. If True, the parameter will be passed as a positional argument to Processor.__init__, otherwise it will be passed as a keyword argument. Defaults to False.

  • identifier (bool) – A value indicating whether this parameter should be used to identify a Processor. If True, the parameter will be used to identify a Processor. This is useful for distinguishing processors, when caching their outputs. Defaults to False.

Return type:

None

__repr__() str[source]

Returns a str representation of the Param instance.

Returns:

Returns a str representation of the Param instance.

Return type:

str

property is_positional: bool

Gets or sets a value indicating whether this parameter can be assigned as a positional argument to Processor.__init__.

Returns:

Returns True if this parameter can be assigned as a positional argument to Processor.__init__ and False otherwise.

Return type:

bool

property is_identifier: bool

Gets or sets a value indicating whether this parameter should be used to identify a Processor.

Returns:

Returns True if this parameter should be used to identify a Processor and False otherwise.

Return type:

bool