Skip to content

Nodes

Continuous

A container for continuous stochastic nodes of a probabilistic model.

Attributes:

Name Type Description
_byx__obj

An internal realization of the node.

_byx__filter_spec

An internal filter specification for obj.

_byx__constraint Constraint

A constraining transformation.

Source code in src/bayinx/nodes/continuous.py
class Continuous[T: PyTree](Stochastic[T]):
    """
    A container for continuous stochastic nodes of a probabilistic model.


    Attributes:
        _byx__obj: An internal realization of the node.
        _byx__filter_spec: An internal filter specification for `obj`.
        _byx__constraint: A constraining transformation.
    """

    _byx__constraint: Constraint


    def __init__(
        self,
        obj: T,
        constraint: Constraint = Identity(),
        filter_spec: Optional[PyTree] = None
    ):
        if filter_spec is None: # Default filter specification
            # Generate empty specification
            filter_spec = jt.map(lambda _: False, obj)

            # Specify float-like leaves
            filter_spec = eqx.tree_at(
                where=lambda obj: obj,
                pytree=filter_spec,
                replace=jt.map(is_float_like, obj),
            )
        else:
            filter_spec = jt.broadcast(filter_spec, obj)

        self._byx__obj = obj
        self._byx__filter_spec = filter_spec
        self._byx__constraint = constraint

Observed

A container for observed nodes of a probabilistic model.

Attributes:

Name Type Description
obj

An internal realization of the node.

_filter_spec

An internal filter specification for obj.

Source code in src/bayinx/nodes/observed.py
class Observed[T: PyTree](Node[T]):
    """
    A container for observed nodes of a probabilistic model.


    Attributes:
        obj: An internal realization of the node.
        _filter_spec: An internal filter specification for `obj`.
    """

    def __init__(
        self, obj: T, filter_spec: Optional[PyTree] = None
    ):
        if filter_spec is None: # Default filter specification
            # Generate empty specification
            filter_spec = jt.map(lambda _: False, obj)

            # Specify array-like leaves
            filter_spec = eqx.tree_at(
                where=lambda obj: obj,
                pytree=filter_spec,
                replace=jt.map(eqx.is_array_like, obj),
            )
        else:
            filter_spec = jt.broadcast(filter_spec, obj)

        self._byx__obj = obj
        self._byx__filter_spec = filter_spec