conform_to_inventory

method of dascore.core.spool.Spool source

conform_to_inventory(
    self ,
    on_unresolved: Literal[‘warn’, ‘raise’, ‘ignore’] = raise,
)-> ‘Self’

Return a spool the inventory describes exactly, patch for patch.

This eager metadata step resolves every row, drops unmatched patches, and splits rows at optical-path changes without loading patch data. Splits occur at sample boundaries without duplicating or losing samples.

Parameters

Parameter Description
on_unresolved What to do with a patch the inventory does not describe — one
carrying no acquisition_key (and given none by a pending
enrich), one carrying a key the
inventory does not resolve to exactly one entry, one reaching
outside every matching epoch, or one with no instants to
resolve at because its time axis is not physical. A patch is
judged over its whole span, so one described at its start but
not at its end is undescribed. “raise” (the default)
fails and names them, “warn” drops them and says so, and
“ignore” discards them silently, which is what an inventory
deliberately covering part of an archive wants.

Raises

PatchError If a patch spans a change of acquisition, or must be subdivided but states no time step to find its samples with. An acquisition change means the two halves were recorded under different configurations, so no subdivision makes it one honest patch, and on_unresolved does not cover it: the inventory describes such a patch twice rather than not at all.

Examples

import dascore as dc
from dascore.examples import inventory_patch_pair

patch, inventory = inventory_patch_pair()
spool = dc.spool(patch).attach_inventory(inventory)
assert len(spool.conform_to_inventory()) == 1

# A patch the inventory says nothing about can be dropped.
other = patch.update_attrs(acquisition_key="DAS.R2D1..OTHER")
mixed = dc.spool([patch, other]).attach_inventory(inventory)
assert len(mixed.conform_to_inventory(on_unresolved="ignore")) == 1