import dascore as dc
from dascore.utils.patch import check_kind
patch = dc.get_example_patch()
assert check_kind(patch, patch.pass_filter(time=(None, 10)))
other = patch.update_attrs(tag="other")
assert not check_kind(patch, other, check_behavior="ignore")
# An unset attribute matches any value for a two-patch operation,
keyed = patch.update_attrs(acquisition_key="A.B.C.D")
assert check_kind(patch, keyed)
# but is a value of its own where patches are partitioned.
assert not check_kind(patch, keyed, check_behavior="ignore", strict=True)check_kind
check_kind(
patch1 ,
patch2 ,
check_behavior: Literal[‘warn’, ‘raise’, ‘ignore’] = raise,
strict: bool = False,
)-> ‘bool’
Return True if two patches are the same kind.
Kind is decided by the attributes named in the config option patch_kind_attrs and nothing else: coordinates, units, history, and the remaining attributes never enter. Patches of different kinds are never combined, whatever their coordinates.
Two-operand callers – operators, ufuncs, Patch.where – leave strict False: a missing value is a wildcard matching anything, and the result carries the union of what the two knew. Callers combining a collection – concatenate, stack, the spool operations – pass strict, because a wildcard is not transitive ("a" matches "" matches "b", yet "a" and "b" conflict) and a partition needs it to be.
Parameters
| Parameter | Description |
|---|---|
| patch1 | The first patch. |
| patch2 | The second patch. |
| check_behavior |
What to do when the kinds differ: ‘raise’ (default) raisesIncompatiblePatchError,‘warn’ warns and returns False, ‘ignore’ returns False quietly. |
| strict | If True, a missing value equals only another missing value. |