timetoshare.validation.containment#

Timeline containment rules.

timetoshare.validation.containment.offset_order(children)[source]#

Return child indices in exact offset order, ties by id.

timetoshare.validation.containment.child_end(timeline, child)[source]#

Return where a child of known length ends on its parent’s axis.

The offset lies on the parent’s axis and the length on the child’s. Where both axes are float, a reader adds the two JSON numbers as doubles, so the end is their double sum, which may differ from the exact sum by a rounding; wherever either axis is int or fraction, the end is the exact sum.

timetoshare.validation.containment.child_ends(timeline)[source]#

Return each child’s end on its parent’s axis, as an exact Fraction.

A child’s end is its offset plus its length. Where the timeline and the child both have number type float, the two JSON numbers are summed in IEEE double arithmetic, as a reader adds them, so the end may differ from the exact sum by a rounding. In every other case (int, fraction, mixed number types, a value with no double such as a Fraction pair or an integer beyond the range of doubles, or a double sum that overflows) the sum is exact. A child with no length, or on another unit than its parent, has end None, except a child of a segment line without a length, whose end is the offset of the next child in offset order.

timetoshare.validation.containment.timeline_containment_problems(timeline, path)[source]#

Yield children off their parent’s axis or beyond its known end.