probsys/sppl

Add size() for spe

Closed this issue · 1 comments

Context: For for the whole-genome simulation we work with very large models. This does the trick:

def size(spe):
    if isinstance(spe, LeafSPE):
        return 1
    if isinstance(spe, BranchSPE):
        return 1  + sum(size(s) for s in spe.children)
    assert False, 'Unknown SPE type: %s' % (repr(spe),)