Model.drop_singletons()

Model.drop_singletons()#

Model.drop_singletons()[source]#

Drops any singleton nodes and variables, i.e. nodes or variables that have neither outputs nor inputs.

Return type:

Self

Notes

While the Var.value_node and Var.var_value_node are no singletons in the node graph, they are still dropped if they belong to a singleton Var.

Examples

>>> import liesel.model as lsl
>>> x1 = lsl.Var.new_obs(1.0, name="x1")
>>> x2 = lsl.Var.new_obs(1.0, name="x2")
>>> m = lsl.Model(x1, x2)
>>> m.drop_singletons()
Model(3 nodes, 0 vars)
>>> list(m.vars)
[]