Collections#

class caskade.NodeCollection(name: str | None = None, link: Node | tuple[Node] | None = None, description: str = '')[source]#

Bases: Node, GetSetValues

Base mixin for collections of nodes that track parameters.

Provides shared functionality for traversing, querying, and converting parameters within a graph of nodes. Subclasses such as NodeTuple and NodeList combine this mixin with a standard Python sequence type.

property dynamic#

Whether any node in this collection has dynamic parameters.

Returns:

True if at least one contained node is dynamic.

Return type:

bool

property dynamic_param_groups: tuple[int]#

Sorted unique group identifiers of all dynamic parameters.

Returns:

Sorted group indices present among the dynamic parameters.

Return type:

tuple of int

property dynamic_params: tuple[Param]#

All dynamic parameters in the graph below this node.

Returns:

Dynamic (non-static, non-pointer) parameters found via topological ordering.

Return type:

tuple of Param

property pointer_params: tuple[Param]#

All pointer parameters in the graph below this node.

Returns:

Parameters that act as pointers to other parameters, found via topological ordering.

Return type:

tuple of Param

property static#

Whether all nodes in this collection are static.

Returns:

True if no contained node is dynamic.

Return type:

bool

property static_params: tuple[Param]#

All static parameters in the graph below this node.

Returns:

Static (non-dynamic, non-pointer) parameters found via topological ordering.

Return type:

tuple of Param

to_dynamic(children_only=True)[source]#

Change all parameters to dynamic parameters.

Parameters:

children_only ((bool, optional)) – If True, only convert the children of this module to dynamic. If False, convert all parameters in the graph below this module. Defaults to True.

to_static(children_only=True)[source]#

Change all parameters to static parameters.

Parameters:

children_only ((bool, optional)) – If True, only convert children of this module. If False, convert all parameters in the graph below this module. Defaults to True.

class caskade.NodeList(iterable=(), name=None)[source]#

Bases: NodeCollection, list

Mutable, ordered collection of nodes.

Behaves like a standard list but also participates in the caskade node graph. All elements must be Node instances. Graph links are automatically updated whenever the list is modified.

Parameters:
  • iterable (iterable of Node, optional) – Nodes to include in the list. Defaults to an empty iterable.

  • name (str, optional) – Human-readable name for this collection node.

append(node)[source]#

Append a node to the list and update graph links.

clear()[source]#

Remove all nodes from the list and update graph links.

extend(iterable)[source]#

Extend the list with nodes from an iterable and update graph links.

insert(index, node)[source]#

Insert a node at the given index and update graph links.

pop(index=-1)[source]#

Remove and return a node at the given index, updating graph links.

remove(value)[source]#

Remove the first occurrence of a node and update graph links.

class caskade.NodeTuple(iterable=None, name=None)[source]#

Bases: NodeCollection, tuple

Immutable, ordered collection of nodes.

Behaves like a standard tuple but also participates in the caskade node graph. All elements must be Node instances and are automatically linked as children upon construction.

Parameters:
  • iterable (iterable of Node, optional) – Nodes to include in the tuple.

  • name (str, optional) – Human-readable name for this collection node.