clip_intervals(
items ,
lo: float ,
hi: float ,
outer: float | None[float, None] = None,
min_field: str = distance_min,
max_field: str = distance_max,
)-> ‘list’
Clip interval items to [lo, hi), dropping those left with no coverage.
Point markers cover nothing but are not nothing: they survive when they fall inside the clip, or on its outermost included endpoint.
Parameters
|
Parameter
|
Description
|
|
items
|
Models whose bounds are held by min_field and max_field, and which support pydantic’s model_copy.
|
|
lo
|
The inclusive start of the clip.
|
|
hi
|
The exclusive end of the clip.
|
|
outer
|
The outermost value the clipped axis holds, if any. A point marker sitting exactly there survives, since nothing beyond it can claim it.
|
|
min_field
|
Name of the field holding each item’s lower bound.
|
|
max_field
|
Name of the field holding each item’s upper bound.
|
Examples
from pydantic import BaseModel
from dascore.utils.intervals import clip_intervals
class Span(BaseModel):
distance_min: float
distance_max: float
clipped = clip_intervals([Span(distance_min=0, distance_max=10)], 2, 6)
clipped[0].distance_min, clipped[0].distance_max