Timespan

class lsst.daf.butler.Timespan

Bases: tuple

A 2-element named tuple for time intervals.

Parameters:
begin : Timespan

Minimum timestamp in the interval (inclusive). None is interpreted as -infinity.

end : Timespan

Maximum timestamp in the interval (exclusive). None is interpreted as +infinity.

Attributes Summary

begin Minimum timestamp in the interval (inclusive).
end Maximum timestamp in the interval (exclusive).

Methods Summary

count($self, value, /) Return number of occurrences of value.
difference(other) Return the one or two timespans that cover the interval(s) that are in self but not other.
index($self, value[, start, stop]) Return first index of value.
intersection() Return a new Timespan that is contained by all of the given ones.
overlaps(other) Test whether this timespan overlaps another.

Attributes Documentation

begin

Minimum timestamp in the interval (inclusive).

None should be interpreted as -infinity.

end

Maximum timestamp in the interval (exclusive).

None should be interpreted as +infinity.

Methods Documentation

count($self, value, /)

Return number of occurrences of value.

difference(other: lsst.daf.butler.core.timespan.Timespan) → Iterator[lsst.daf.butler.core.timespan.Timespan]

Return the one or two timespans that cover the interval(s) that are in self but not other.

This is implemented as an iterator because the result may be zero, one, or two Timespan objects, depending on the relationship between the operands.

Parameters:
other : Timespan

Timespan to subtract.

Yields:
result : Timespan

A Timespan that is contained by self but does not overlap other.

index($self, value, start=0, stop=sys.maxsize, /)

Return first index of value.

Raises ValueError if the value is not present.

intersection() → Optional[lsst.daf.butler.core.timespan.Timespan]

Return a new Timespan that is contained by all of the given ones.

Parameters:
*args

All positional arguments are Timespan instances.

Returns:
intersection : Timespan or None

The intersection timespan, or None, if there is no intersection or no arguments.

overlaps(other: lsst.daf.butler.core.timespan.Timespan) → Any

Test whether this timespan overlaps another.

Parameters:
other : Timespan

Another timespan whose begin and end values can be compared with those of self with the >= operator, yielding values that can be passed to ops.or_ and/or ops.and_.

Returns:
overlaps : Any

The result of the overlap. When ops is operator, this will be a bool. If ops is sqlachemy.sql, it will be a boolean column expression.