import dascore as dc
from dascore.examples import inventory_patch_pair
patch, inventory = inventory_patch_pair()
spool = dc.spool(patch).attach_inventory(inventory)
# The example path annotates two zones along the fiber.
zones = spool.expand_by("zone")
assert len(zones) == 2
assert set(zones.get_contents()["zone"]) == {"north", "south"}
# Which can be narrowed by a glob over the values.
assert len(spool.expand_by("zone", include="nor*")) == 1expand_by
expand_by(
self ,
name: str ,
include: str | collections.abc.Sequence[str, collections.abc.Sequence[str], None] = None,
exclude: str | collections.abc.Sequence[str, collections.abc.Sequence[str], None] = None,
stamp: bool = True,
)-> ‘Self’
Expand the spool into one patch per value of an inventory coordinate.
Most often an annotation group. Every kind of group expands: a categorical one by each of its strings, a membership group into the channels it includes and those it does not, and a numeric one by each distinct measurement. Intervals of one group may overlap, but a channel still holds only one of its values, so the outputs of one call divide the fiber rather than share it. A patch whose channels take several values becomes several patches — this can greatly expand the spool.
Parameters
| Parameter | Description |
|---|---|
| name | The inventory-derived coordinate to expand by. |
| include, exclude |
Glob patterns matched against each value written as a string, which is what lets one spelling cover all three kinds of group: "hole_*" reads a categorical one, "Tru*"a membership one, and "1.*" a numeric one. Selecting on thestamp afterwards compares typed values instead, so the two are not interchangeable. With include, only values matchingone of them are kept; exclude drops the values it matches,and wins where both match. |
| stamp |
Whether to record the value on each output patch as an attr named after the coordinate, so overlapping siblings stay distinguishable and later operations can select on it. Pass False for a nested expansion, where the second should not overwrite the first. |