hyperiax.Tree¶
- class hyperiax.Tree(topology, schema, data)[source]¶
Bases:
objectA topology + a typed dict of
(N, *trailing)arrays.Construction is always functional: every “mutator” returns a new Tree sharing the same Topology and (usually) Schema, with replaced data.
Data fields are reachable two ways:
tree['value'](dict-style, the safe form when the field name is dynamic or collides with a reserved name) andtree.value(attribute-style, the canonical form mirroringnode.value/children.valueinside a sweep).- __init__(topology, schema, data)¶
Methods
__init__(topology, schema, data)drop(*names)Drop fields; returns a Tree with reduced schema and data.
empty(topology, schema)Allocate a Tree of zeros with the declared schema.
from_data(topology, data)Build a Tree from an existing data dict; schema is inferred from arrays.
set(**fields)Replace whole fields.
update(**fields)Add brand-new fields.
Attributes
- classmethod from_data(topology, data)[source]¶
Build a Tree from an existing data dict; schema is inferred from arrays.
- set(**fields)[source]¶
Replace whole fields. Each value must already match
(N, *spec.shape).- Return type:
- Parameters:
fields (Array)
- property at: _AtAccessor¶
tree.at[indices].set(field=values).Mirrors
jax.numpy.ndarray.at. The returned indexer supportsset,add,multiply,min,max(all take fields as keyword arguments and return a newTree) andget(returns adictof every field evaluated atindices).- Type:
JAX-style scatter accessor
- update(**fields)[source]¶
Add brand-new fields. Values can be a FieldSpec, a shape tuple, or an array.
Note: this changes the pytree structure and will invalidate any JIT caches keyed on the previous structure. Prefer
Tree.empty(topo, full_schema)when you know all the fields up front (the typical case in a sweep pipeline).- Return type: