vivarium-collective / bigraph-schema

compositional type schemas
Apache License 2.0
1 stars 1 forks source link

Tree type remove and add with lists of paths #25

Closed eagmon closed 11 months ago

eagmon commented 1 year ago

I want to add/remove nodes from a tree type by providing a list of paths, like this:

place_schema = {
    '_type': 'tree[float]',
}

place_state1 = {
    'node1': 1.0,
    'node2': {
        'node2.1': 2.0,
        'node2.2': 2.1
    }
}

update = {
    '_remove': [
        ['node1'], 
        ['node2', 'node2.2'],
    ],
}

place_state2 = types.apply(
    place_schema,
    place_state1,
    update
)