SliceRegisterNode¶
- class samplomatic.samplex.nodes.SliceRegisterNode(input_type: VirtualType, output_type: VirtualType, input_register_name: str, output_register_name: str, slice_idxs: slice | Sequence[int], force_copy: bool = False)[source]¶
Bases:
EvaluationNodeA node to slice a register.
Note
Slicing of a register can alternatively be done using a
CombineRegistersNode, providingoperandsof length1. However, usingSliceRegisterNodeis recommended because itsevaluate()method is optimized for slicing a single register.- Parameters:
input_type – The type of the input register.
output_type – The type of the output register.
input_register_name – The name of the input register.
output_register_name – The name of the output register.
slice_idxs – The indices used to slice the register.
force_copy – Whether or not to force output register to be a copy instead of a view of the input register.
- Raises:
SamplexConstructionError – If
slice_idxshas the wrong shape.
Attributes Summary
The virtual gate type of outgoing registers.
Methods Summary
evaluate(registers, *_)Evaluate this node.
Return a manifest of new virtual registers that this node instantiates.
Return a manifest of which virtual register values this node needs to read from.
validate_and_update(register_descriptions)Validate provided register descriptions are compatible, update with changes.
Attributes Documentation
- outgoing_register_type¶
Methods Documentation
- evaluate(registers, *_)[source]¶
Evaluate this node.
- Parameters:
registers – At least those registers needed by this node to read from or write to.
parameter_values – Parameter values to use during evaluation.
- Raises:
SamplexRuntimeError – If the number of parameter values received does not equal the number required by this node.
- instantiates()[source]¶
Return a manifest of new virtual registers that this node instantiates.
Note
To change the type or size of a register, both instantiate and remove it.
Do not specify
reads_from()orwrites_to()for an instantiated register, these powers are implicit.
- reads_from()[source]¶
Return a manifest of which virtual register values this node needs to read from.
- validate_and_update(register_descriptions)[source]¶
Validate provided register descriptions are compatible, update with changes.
This method can be used by a samplex to determine when a node execution order has well-defined dependencies before sampling begins.
- Parameters:
register_descriptions – A map from existing register names to their size and type.