timespan

Tools for modeling and manipulating timespans.

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true ]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0 ]; edge [color=lightslategrey, penwidth=1 ]; subgraph "cluster_abjad.timespan" { graph [label="abjad.timespan"]; node [color=1]; "abjad.timespan.OffsetCounter" [URL="../api/abjad/timespan.html#abjad.timespan.OffsetCounter", color=black, fontcolor=white, label="Offset\nCounter", target=_top]; "abjad.timespan.Timespan" [URL="../api/abjad/timespan.html#abjad.timespan.Timespan", color=black, fontcolor=white, label=Timespan, target=_top]; "abjad.timespan.TimespanList" [URL="../api/abjad/timespan.html#abjad.timespan.TimespanList", color=black, fontcolor=white, label="Timespan\nList", target=_top]; } subgraph cluster_builtins { graph [label=builtins]; node [color=2]; "builtins.list" [URL="https://docs.python.org/3.10/library/stdtypes.html#list", label=list, target=_top]; "builtins.object" [URL="https://docs.python.org/3.10/library/functions.html#object", label=object, target=_top]; "builtins.object" -> "builtins.list" [minlen=1]; } "builtins.list" -> "abjad.timespan.TimespanList" [minlen=1]; "builtins.object" -> "abjad.timespan.OffsetCounter" [minlen=1]; "builtins.object" -> "abjad.timespan.Timespan" [minlen=2]; }


Classes

OffsetCounter

Offset counter.

class abjad.timespan.OffsetCounter(items=(), item_class=<class 'abjad.duration.Offset'>)[source]

Offset counter.

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 16),
...         abjad.Timespan(5, 12),
...         abjad.Timespan(-2, 8),
...     ]
... )
>>> timespan_operand = abjad.Timespan(6, 10)
>>> timespans = timespans - timespan_operand
>>> offset_counter = abjad.OffsetCounter(timespans)
>>> for item in offset_counter.items.items():
...     item
... 
(Offset((-2, 1)), 1)
(Offset((0, 1)), 1)
(Offset((5, 1)), 1)
(Offset((6, 1)), 3)
(Offset((10, 1)), 2)
(Offset((12, 1)), 1)
(Offset((16, 1)), 1)
>>> abjad.show(offset_counter, scale=0.5)  

Attributes Summary

__eq__

Return self==value.

__post_init__

__repr__

Return repr(self).


Special methods

overridden __eq__(other)

Return self==value.

__post_init__()[source]
overridden __repr__()

Return repr(self).


Timespans

Timespan

Timespan.

TimespanList

Timespan list.

class abjad.timespan.Timespan(start_offset=None, stop_offset=None, annotation=None)[source]

Timespan.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 12)
>>> timespan_3 = abjad.Timespan(-2, 2)
>>> timespan_4 = abjad.Timespan(10, 20)

Annotations work like this:

>>> annotated_timespan = abjad.Timespan(
...     annotation=["a", "b", "c", "foo"],
...     start_offset=(1, 4),
...     stop_offset=(7, 8),
... )
>>> annotated_timespan.annotation
['a', 'b', 'c', 'foo']

Annotated timespans maintain their annotations duration mutation:

>>> left, right = annotated_timespan.split_at_offset((1, 2))
>>> left.annotation.append("foo")
>>> right
Timespan(Offset((1, 2)), Offset((7, 8)), annotation=['a', 'b', 'c', 'foo', 'foo'])

Timespans are closed-open intervals.


Attributes Summary

__and__

Logical AND of two timespans.

__contains__

Is true when timespan contains argument.

__eq__

Compares start_offset, stop_offset.

__ge__

Is true when argument start offset is greater or equal to timespan start offset.

__gt__

Is true when argument start offset is greater than timespan start offset.

__hash__

Return hash(self).

__le__

Is true when argument start offset is less than or equal to timespan start offset.

__len__

Defined equal to 1 for all timespans.

__lt__

Is true when argument start offset is less than timespan start offset.

__or__

Logical OR of two timespans.

__post_init__

__repr__

Gets repr.

__sub__

Subtract argument from timespan.

__xor__

Logical XOR of two timespans.

axis

Gets arithmetic mean of timespan start- and stop-offsets.

divide_by_ratio

Divides timespan by ratio.

duration

Gets duration of timespan.

get_overlap_with_timespan

Gets duration of overlap with timespan.

offsets

Gets offsets.

reflect

Reflects timespan about axis.

round_offsets

Rounds timespan offsets to multiple of multiplier.

scale

Scales timespan by multiplier.

set_duration

Sets timespan duration to duration.

set_offsets

Sets timespan start offset to start_offset and stop offset to stop_offset.

split_at_offset

Split into two parts when offset happens during timespan:

split_at_offsets

Split into one or more parts when offsets happens during timespan:

stretch

Stretches timespan by multiplier relative to anchor.

translate

Translates timespan by translation.

translate_offsets

Translates timespan start offset by start_offset_translation and stop offset by stop_offset_translation.

wellformed

Is true when timespan start offset preceeds timespan stop offset.


Special methods

__and__(argument)[source]

Logical AND of two timespans.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 12)
>>> timespan_3 = abjad.Timespan(-2, 2)
>>> timespan_4 = abjad.Timespan(10, 20)
>>> timespan_1 & timespan_2
TimespanList([Timespan(Offset((5, 1)), Offset((10, 1)))])
>>> timespan_1 & timespan_3
TimespanList([Timespan(Offset((0, 1)), Offset((2, 1)))])
>>> timespan_1 & timespan_4
TimespanList([])
>>> timespan_2 & timespan_3
TimespanList([])
>>> timespan_2 & timespan_4
TimespanList([Timespan(Offset((10, 1)), Offset((12, 1)))])
>>> timespan_3 & timespan_4
TimespanList([])
Return type:

TimespanList

__contains__(argument)[source]

Is true when timespan contains argument.

Works with offsets:

>>> timespan = abjad.Timespan(0, (1, 4))
>>> -1 in timespan
False
>>> 0 in timespan
True
>>> abjad.Offset(1, 8) in timespan
True
>>> abjad.Offset(1, 4) in timespan
True
>>> abjad.Offset(1, 2) in timespan
False

Works with other timespans:

>>> timespan = abjad.Timespan(0, (1, 4))
>>> abjad.Timespan(0, (1, 4)) in timespan
True
>>> abjad.Timespan((1, 16), (2, 16)) in timespan
True
>>> abjad.Timespan(0, (1, 2)) in timespan
False
Return type:

bool

overridden __eq__(argument)[source]

Compares start_offset, stop_offset.

>>> abjad.Timespan(1, 3) == abjad.Timespan(1, 3)
True
>>> abjad.Timespan(1, 3) == abjad.Timespan(2, 3)
False
Return type:

bool

overridden __ge__(argument)[source]

Is true when argument start offset is greater or equal to timespan start offset.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 12)
>>> timespan_3 = abjad.Timespan(-2, 2)
>>> timespan_2 >= timespan_3
True
>>> timespan_1 >= timespan_2
False
Return type:

bool

overridden __gt__(argument)[source]

Is true when argument start offset is greater than timespan start offset.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 12)
>>> timespan_3 = abjad.Timespan(-2, 2)
>>> timespan_2 > timespan_3
True
>>> timespan_1 > timespan_2
False
Return type:

bool

overridden __hash__()

Return hash(self).

overridden __le__(argument)[source]

Is true when argument start offset is less than or equal to timespan start offset.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 12)
>>> timespan_3 = abjad.Timespan(-2, 2)
>>> timespan_2 <= timespan_3
False
>>> timespan_1 <= timespan_2
True
Return type:

bool

__len__()[source]

Defined equal to 1 for all timespans.

>>> timespan = abjad.Timespan(0, 10)
>>> len(timespan)
1
Return type:

int

overridden __lt__(argument)[source]

Is true when argument start offset is less than timespan start offset.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 12)
>>> timespan_3 = abjad.Timespan(-2, 2)
>>> timespan_1 < timespan_2
True
>>> timespan_2 < timespan_3
False
Return type:

bool

overridden __or__(argument)[source]

Logical OR of two timespans.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 12)
>>> timespan_3 = abjad.Timespan(-2, 2)
>>> timespan_4 = abjad.Timespan(10, 20)
>>> timespans = timespan_1 | timespan_2
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((12, 1)))
>>> timespans = timespan_1 | timespan_3
>>> for _ in timespans:
...     _
... 
Timespan(Offset((-2, 1)), Offset((10, 1)))
>>> timespans = timespan_1 | timespan_4
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((20, 1)))
>>> timespans = timespan_2 | timespan_3
>>> for _ in timespans:
...     _
... 
Timespan(Offset((-2, 1)), Offset((2, 1)))
Timespan(Offset((5, 1)), Offset((12, 1)))
>>> timespans = timespan_2 | timespan_4
>>> for _ in timespans:
...     _
... 
Timespan(Offset((5, 1)), Offset((20, 1)))
>>> timespans = timespan_3 | timespan_4
>>> for _ in timespans:
...     _
... 
Timespan(Offset((-2, 1)), Offset((2, 1)))
Timespan(Offset((10, 1)), Offset((20, 1)))
Return type:

TimespanList

__post_init__()[source]
overridden __repr__()[source]

Gets repr.

Return type:

str

__sub__(argument)[source]

Subtract argument from timespan.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 12)
>>> timespan_3 = abjad.Timespan(-2, 2)
>>> timespan_4 = abjad.Timespan(10, 20)
>>> timespan_1 - timespan_1
TimespanList([])
>>> timespan_1 - timespan_2
TimespanList([Timespan(Offset((0, 1)), Offset((5, 1)))])
>>> timespan_1 - timespan_3
TimespanList([Timespan(Offset((2, 1)), Offset((10, 1)))])
>>> timespan_1 - timespan_4
TimespanList([Timespan(Offset((0, 1)), Offset((10, 1)))])
>>> timespan_2 - timespan_1
TimespanList([Timespan(Offset((10, 1)), Offset((12, 1)))])
>>> timespan_2 - timespan_2
TimespanList([])
>>> timespan_2 - timespan_3
TimespanList([Timespan(Offset((5, 1)), Offset((12, 1)))])
>>> timespan_2 - timespan_4
TimespanList([Timespan(Offset((5, 1)), Offset((10, 1)))])
>>> timespan_3 - timespan_3
TimespanList([])
>>> timespan_3 - timespan_1
TimespanList([Timespan(Offset((-2, 1)), Offset((0, 1)))])
>>> timespan_3 - timespan_2
TimespanList([Timespan(Offset((-2, 1)), Offset((2, 1)))])
>>> timespan_3 - timespan_4
TimespanList([Timespan(Offset((-2, 1)), Offset((2, 1)))])
>>> timespan_4 - timespan_4
TimespanList([])
>>> timespan_4 - timespan_1
TimespanList([Timespan(Offset((10, 1)), Offset((20, 1)))])
>>> timespan_4 - timespan_2
TimespanList([Timespan(Offset((12, 1)), Offset((20, 1)))])
>>> timespan_4 - timespan_3
TimespanList([Timespan(Offset((10, 1)), Offset((20, 1)))])

Returns timespan list.

Return type:

TimespanList

__xor__(argument)[source]

Logical XOR of two timespans.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 12)
>>> timespan_3 = abjad.Timespan(-2, 2)
>>> timespan_4 = abjad.Timespan(10, 20)
>>> timespans = timespan_1 ^ timespan_2
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((5, 1)))
Timespan(Offset((10, 1)), Offset((12, 1)))
>>> timespans = timespan_1 ^ timespan_3
>>> for _ in timespans:
...     _
... 
Timespan(Offset((-2, 1)), Offset((0, 1)))
Timespan(Offset((2, 1)), Offset((10, 1)))
>>> timespans = timespan_1 ^ timespan_4
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((10, 1)))
Timespan(Offset((10, 1)), Offset((20, 1)))
>>> timespans = timespan_2 ^ timespan_3
>>> for _ in timespans:
...     _
... 
Timespan(Offset((-2, 1)), Offset((2, 1)))
Timespan(Offset((5, 1)), Offset((12, 1)))
>>> timespans = timespan_2 ^ timespan_4
>>> for _ in timespans:
...     _
... 
Timespan(Offset((5, 1)), Offset((10, 1)))
Timespan(Offset((12, 1)), Offset((20, 1)))
>>> timespans = timespan_3 ^ timespan_4
>>> for _ in timespans:
...     _
... 
Timespan(Offset((-2, 1)), Offset((2, 1)))
Timespan(Offset((10, 1)), Offset((20, 1)))
Return type:

TimespanList


Methods

divide_by_ratio(ratio)[source]

Divides timespan by ratio.

>>> timespan = abjad.Timespan((1, 2), (3, 2))
>>> for x in timespan.divide_by_ratio((1, 2, 1)):
...     x
... 
Timespan(Offset((1, 2)), Offset((3, 4)))
Timespan(Offset((3, 4)), Offset((5, 4)))
Timespan(Offset((5, 4)), Offset((3, 2)))
Return type:

tuple[Timespan, ...]

get_overlap_with_timespan(timespan)[source]

Gets duration of overlap with timespan.

>>> timespan_1 = abjad.Timespan(0, 15)
>>> timespan_2 = abjad.Timespan(5, 10)
>>> timespan_3 = abjad.Timespan(6, 6)
>>> timespan_4 = abjad.Timespan(12, 22)
>>> timespan_1.get_overlap_with_timespan(timespan_1)
Duration(15, 1)
>>> timespan_1.get_overlap_with_timespan(timespan_2)
Duration(5, 1)
>>> timespan_1.get_overlap_with_timespan(timespan_3)
Duration(0, 1)
>>> timespan_1.get_overlap_with_timespan(timespan_4)
Duration(3, 1)
>>> timespan_2.get_overlap_with_timespan(timespan_2)
Duration(5, 1)
>>> timespan_2.get_overlap_with_timespan(timespan_3)
Duration(0, 1)
>>> timespan_2.get_overlap_with_timespan(timespan_4)
Duration(0, 1)
>>> timespan_3.get_overlap_with_timespan(timespan_3)
Duration(0, 1)
>>> timespan_3.get_overlap_with_timespan(timespan_4)
Duration(0, 1)
>>> timespan_4.get_overlap_with_timespan(timespan_4)
Duration(10, 1)
Return type:

Optional[Duration]

reflect(axis=None)[source]

Reflects timespan about axis.

Reverse timespan about timespan axis:

>>> abjad.Timespan(3, 6).reflect()
Timespan(Offset((3, 1)), Offset((6, 1)))

Reverse timespan about arbitrary axis:

>>> abjad.Timespan(3, 6).reflect(axis=abjad.Offset(10))
Timespan(Offset((14, 1)), Offset((17, 1)))
Return type:

Timespan

round_offsets(multiplier, anchor=Horizontal.LEFT, must_be_wellformed=True)[source]

Rounds timespan offsets to multiple of multiplier.

>>> timespan = abjad.Timespan((1, 5), (4, 5))
>>> timespan.round_offsets(1)
Timespan(Offset((0, 1)), Offset((1, 1)))
>>> timespan.round_offsets(2)
Timespan(Offset((0, 1)), Offset((2, 1)))
>>> timespan.round_offsets(2, anchor=abjad.RIGHT)
Timespan(Offset((-2, 1)), Offset((0, 1)))
>>> timespan.round_offsets(2, anchor=abjad.RIGHT, must_be_wellformed=False)
Timespan(Offset((0, 1)), Offset((0, 1)))
Return type:

Timespan

scale(multiplier, anchor=Horizontal.LEFT)[source]

Scales timespan by multiplier. :rtype: Timespan

>>> timespan = abjad.Timespan(3, 6)

Scale timespan relative to timespan start offset:

>>> timespan.scale(abjad.Fraction(2))
Timespan(Offset((3, 1)), Offset((9, 1)))

Scale timespan relative to timespan stop offset:

>>> timespan.scale(abjad.Fraction(2), anchor=abjad.RIGHT)
Timespan(Offset((0, 1)), Offset((6, 1)))
set_duration(duration)[source]

Sets timespan duration to duration.

>>> timespan = abjad.Timespan((1, 2), (3, 2))
>>> timespan.set_duration((3, 5))
Timespan(Offset((1, 2)), Offset((11, 10)))
Return type:

Timespan

set_offsets(start_offset=None, stop_offset=None)[source]

Sets timespan start offset to start_offset and stop offset to stop_offset.

>>> timespan = abjad.Timespan((1, 2), (3, 2))
>>> timespan.set_offsets(stop_offset=(7, 8))
Timespan(Offset((1, 2)), Offset((7, 8)))

Subtracts negative start_offset from existing stop offset:

>>> timespan.set_offsets(start_offset=(-1, 2))
Timespan(Offset((1, 1)), Offset((3, 2)))

Subtracts negative stop_offset from existing stop offset:

>>> timespan.set_offsets(stop_offset=(-1, 2))
Timespan(Offset((1, 2)), Offset((1, 1)))
Return type:

Timespan

split_at_offset(offset)[source]

Split into two parts when offset happens during timespan:

>>> timespan = abjad.Timespan(0, 5)
>>> left, right = timespan.split_at_offset((2, 1))
>>> left
Timespan(Offset((0, 1)), Offset((2, 1)))
>>> right
Timespan(Offset((2, 1)), Offset((5, 1)))

Otherwise return a copy of timespan:

>>> timespan.split_at_offset((12, 1))[0]
Timespan(Offset((0, 1)), Offset((5, 1)))
Return type:

TimespanList

split_at_offsets(offsets)[source]

Split into one or more parts when offsets happens during timespan:

>>> timespan = abjad.Timespan(0, 10)
>>> timespans = timespan.split_at_offsets((1, 3, 7))
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((1, 1)))
Timespan(Offset((1, 1)), Offset((3, 1)))
Timespan(Offset((3, 1)), Offset((7, 1)))
Timespan(Offset((7, 1)), Offset((10, 1)))

Otherwise return a timespan list containing a copy of timespan:

>>> timespans = timespan.split_at_offsets((-100,))
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((10, 1)))
Return type:

TimespanList

stretch(multiplier, anchor=None)[source]

Stretches timespan by multiplier relative to anchor.

Stretch relative to timespan start offset:

>>> abjad.Timespan(3, 10).stretch(abjad.Fraction(2))
Timespan(Offset((3, 1)), Offset((17, 1)))

Stretch relative to timespan stop offset:

>>> abjad.Timespan(3, 10).stretch(abjad.Fraction(2), abjad.Offset(10))
Timespan(Offset((-4, 1)), Offset((10, 1)))

Stretch relative to offset prior to timespan:

>>> abjad.Timespan(3, 10).stretch(abjad.Fraction(2), abjad.Offset(0, 1))
Timespan(Offset((6, 1)), Offset((20, 1)))

Stretch relative to offset after timespan:

>>> abjad.Timespan(3, 10).stretch(abjad.Fraction(3), abjad.Offset(12))
Timespan(Offset((-15, 1)), Offset((6, 1)))

Stretch relative to offset that happens during timespan:

>>> abjad.Timespan(3, 10).stretch(abjad.Fraction(2), abjad.Offset(4))
Timespan(Offset((2, 1)), Offset((16, 1)))
Return type:

Timespan

translate(translation=None)[source]

Translates timespan by translation.

>>> timespan = abjad.Timespan(5, 10)
>>> timespan.translate(2)
Timespan(Offset((7, 1)), Offset((12, 1)))
Return type:

Timespan

translate_offsets(start_offset_translation=None, stop_offset_translation=None)[source]

Translates timespan start offset by start_offset_translation and stop offset by stop_offset_translation.

>>> timespan = abjad.Timespan((1, 2), (3, 2))
>>> timespan.translate_offsets(start_offset_translation=(-1, 8))
Timespan(Offset((3, 8)), Offset((3, 2)))
Return type:

Timespan


Read-only properties

axis

Gets arithmetic mean of timespan start- and stop-offsets.

>>> abjad.Timespan(0, 10).axis
Offset((5, 1))
duration

Gets duration of timespan.

>>> abjad.Timespan(0, 10).duration
Duration(10, 1)
offsets

Gets offsets.

>>> abjad.Timespan(0, 10).offsets
(Offset((0, 1)), Offset((10, 1)))
wellformed

Is true when timespan start offset preceeds timespan stop offset.

>>> abjad.Timespan(0, 10).wellformed
True
class abjad.timespan.TimespanList(argument=())[source]

Timespan list.

Contiguous timespan list:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((3, 1)))
Timespan(Offset((3, 1)), Offset((6, 1)))
Timespan(Offset((6, 1)), Offset((10, 1)))

Overlapping timespan list:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 16),
...         abjad.Timespan(5, 12),
...         abjad.Timespan(-2, 8),
...         abjad.Timespan(15, 20),
...         abjad.Timespan(24, 30),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((16, 1)))
Timespan(Offset((5, 1)), Offset((12, 1)))
Timespan(Offset((-2, 1)), Offset((8, 1)))
Timespan(Offset((15, 1)), Offset((20, 1)))
Timespan(Offset((24, 1)), Offset((30, 1)))

Empty timespan list:

>>> abjad.TimespanList()
TimespanList([])

Coerces input:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, (1, 2)),
...         ((1, 2), (3, 4)),
...         abjad.Timespan((3, 4), 1),
...     ]
... )
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((1, 2)))
Timespan(Offset((1, 2)), Offset((3, 4)))
Timespan(Offset((3, 4)), Offset((1, 1)))

Operations on timespan currently work in place.


Attributes Summary

__and__

Keeps material that intersects timespan.

__eq__

Return self==value.

__invert__

Inverts timespans.

__repr__

Gets repr.

__setitem__

Coerces argument and sets at i.

__sub__

Deletes material that intersects timespan.

all_are_contiguous

Is true when all timespans are contiguous.

all_are_nonoverlapping

Is true when all timespans are nonoverlapping.

all_are_wellformed

Is true when all timespans are wellformed.

append

Coerces item and appends.

axis

Gets axis defined equal to arithmetic mean of start- and stop-offsets.

clip_timespan_durations

Clips timespan durations.

compute_logical_and

Computes logical AND of timespans.

compute_logical_or

Computes logical OR of timespans.

compute_logical_xor

Computes logical XOR of timespans.

compute_overlap_factor

Computes overlap factor of timespans.

compute_overlap_factor_mapping

Computes overlap factor for each consecutive offset pair in timespans.

count_offsets

Counts offsets.

duration

Gets duration of timespan list.

explode

Explodes timespans into timespan lists, avoiding overlap, and distributing density as evenly as possible.

extend

Coerces items and extends.

get_timespan_that_satisfies_time_relation

Gets timespan that satisifies time_relation.

get_timespans_that_satisfy_time_relation

Gets timespans that satisfy time_relation.

has_timespan_that_satisfies_time_relation

Is true when list has matching timespan.

is_sorted

Is true when timespans are in time order.

partition

Partitions timespans into timespan lists.

reflect

Reflects timespans.

remove

Coerces item and removes.

remove_degenerate_timespans

Removes degenerate timespans.

repeat_to_stop_offset

Repeats timespans to stop_offset.

rotate

Rotates by count contiguous timespans.

round_offsets

Rounds offsets of timespans in list to multiples of multiplier.

scale

Scales timespan by multiplier relative to anchor.

split_at_offset

Splits timespans at offset.

split_at_offsets

Splits timespans at offsets.

start_offset

Gets start offset.

stop_offset

Gets stop offset.

stretch

Stretches timespans by multiplier relative to anchor.

timespan

Gets timespan of timespan list.

translate

Translates timespans by translation.

translate_offsets

Translates timespans by start_offset_translation and stop_offset_translation.


Special methods

(list).__add__(value, /)

Return self+value.

__and__(timespan)[source]

Keeps material that intersects timespan.

Keeps material that intersects timespan:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 16),
...         abjad.Timespan(5, 12),
...         abjad.Timespan(-2, 8),
...     ]
... )
>>> abjad.show(timespans, range_=(-2, 12), scale=0.5)  
>>> timespan = abjad.Timespan(5, 10)
>>> timespans = timespans & timespan
>>> abjad.show(timespans, range_=(-2, 12), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((5, 1)), Offset((8, 1)))
Timespan(Offset((5, 1)), Offset((10, 1)))
Timespan(Offset((5, 1)), Offset((10, 1)))
Return type:

TimespanList

(list).__class_getitem__()

See PEP 585

(list).__contains__(key, /)

Return key in self.

(list).__delitem__(key, /)

Delete self[key].

overridden __eq__(other)

Return self==value.

(list).__ge__(value, /)

Return self>=value.

(list).__getitem__()

x.__getitem__(y) <==> x[y]

(list).__gt__(value, /)

Return self>value.

(list).__iadd__(value, /)

Implement self+=value.

(list).__imul__(value, /)

Implement self*=value.

__invert__()[source]

Inverts timespans.

Inverts timespans:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(-2, 8),
...         abjad.Timespan(15, 20),
...         abjad.Timespan(24, 30),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> abjad.show(~timespans, range_=(-2, 30), scale=0.5)  
>>> for _ in ~timespans:
...     _
... 
Timespan(Offset((8, 1)), Offset((15, 1)))
Timespan(Offset((20, 1)), Offset((24, 1)))

Inverts contiguous timespans:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> ~timespans
TimespanList([])
Return type:

TimespanList

(list).__iter__()

Implement iter(self).

(list).__le__(value, /)

Return self<=value.

(list).__len__()

Return len(self).

(list).__lt__(value, /)

Return self<value.

(list).__mul__(value, /)

Return self*value.

(list).__ne__(value, /)

Return self!=value.

(list).__new__(**kwargs)
overridden __repr__()[source]

Gets repr.

(list).__reversed__()

Return a reverse iterator over the list.

(list).__rmul__(value, /)

Return value*self.

overridden __setitem__(i, argument)[source]

Coerces argument and sets at i.

__sub__(timespan)[source]

Deletes material that intersects timespan.

Deletes material that intersects timespan:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 16),
...         abjad.Timespan(5, 12),
...         abjad.Timespan(-2, 8),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespan = abjad.Timespan(5, 10)
>>> timespans = timespans - timespan
>>> for _ in timespans:
...     _
... 
Timespan(Offset((-2, 1)), Offset((5, 1)))
Timespan(Offset((0, 1)), Offset((5, 1)))
Timespan(Offset((10, 1)), Offset((12, 1)))
Timespan(Offset((10, 1)), Offset((16, 1)))
>>> abjad.show(timespans, scale=0.5)  
Return type:

TimespanList


Methods

overridden append(item)[source]

Coerces item and appends.

(list).clear()

Remove all items from list.

clip_timespan_durations(minimum=None, maximum=None, anchor=Horizontal.LEFT)[source]

Clips timespan durations.

Clips timespan durations:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 1),
...         abjad.Timespan(0, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans = timespans.clip_timespan_durations(minimum=5)
>>> abjad.show(timespans, range_=(0, 10), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((5, 1)))
Timespan(Offset((0, 1)), Offset((10, 1)))

Clips timespan durations:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 1),
...         abjad.Timespan(0, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans = timespans.clip_timespan_durations(maximum=5)
>>> abjad.show(timespans, range_=(0, 10), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((1, 1)))
Timespan(Offset((0, 1)), Offset((5, 1)))

Clips timespan durations:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 1),
...         abjad.Timespan(0, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans = timespans.clip_timespan_durations(
...     minimum=3,
...     maximum=7,
... )
>>> abjad.show(timespans, range_=(0, 10), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((3, 1)))
Timespan(Offset((0, 1)), Offset((7, 1)))

Clips timespan durations:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 1),
...         abjad.Timespan(0, 10),
...     ]
... )
>>> abjad.show(timespans, range_=(-2, 10), scale=0.5)  
>>> timespans = timespans.clip_timespan_durations(
...     minimum=3,
...     maximum=7,
...     anchor=abjad.RIGHT,
... )
>>> abjad.show(timespans, range_=(-2, 10), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((-2, 1)), Offset((1, 1)))
Timespan(Offset((3, 1)), Offset((10, 1)))
Return type:

TimespanList

compute_logical_and()[source]

Computes logical AND of timespans.

Computes logical AND:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans = timespans.compute_logical_and()
>>> abjad.show(timespans, range_=(0, 10), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((10, 1)))

Computes logical AND:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 10),
...         abjad.Timespan(5, 12),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans = timespans.compute_logical_and()
>>> abjad.show(timespans, range_=(0, 12), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((5, 1)), Offset((10, 1)))

Computes logical AND:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 10),
...         abjad.Timespan(5, 12),
...         abjad.Timespan(-2, 8),
...     ]
... )
>>> abjad.show(timespans, range_=(-2, 12), scale=0.5)  
>>> timespans = timespans.compute_logical_and()
>>> abjad.show(timespans, range_=(-2, 12), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((5, 1)), Offset((8, 1)))

Same as setwise intersection.

Operates in place and returns timespan list.

Return type:

TimespanList

compute_logical_or()[source]

Computes logical OR of timespans.

>>> timespans = abjad.TimespanList()
>>> timespans = timespans.compute_logical_or()
>>> timespans
TimespanList([])
>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans = timespans.compute_logical_or()
>>> abjad.show(timespans, range_=(0, 10), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((10, 1)))
>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 10),
...         abjad.Timespan(5, 12),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans = timespans.compute_logical_or()
>>> abjad.show(timespans, range_=(0, 12), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((12, 1)))
>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 10),
...         abjad.Timespan(5, 12),
...         abjad.Timespan(-2, 2),
...     ]
... )
>>> abjad.show(timespans, range_=(-2, 12), scale=0.5)  
>>> timespans = timespans.compute_logical_or()
>>> abjad.show(timespans, range_=(-2, 12), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((-2, 1)), Offset((12, 1)))
>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(-2, 2),
...         abjad.Timespan(10, 20),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans = timespans.compute_logical_or()
>>> abjad.show(timespans, range_=(-2, 20), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((-2, 1)), Offset((2, 1)))
Timespan(Offset((10, 1)), Offset((20, 1)))

Operates in place and returns timespan list.

Return type:

TimespanList

compute_logical_xor()[source]

Computes logical XOR of timespans.

>>> timespans = abjad.TimespanList()
>>> timespans = timespans.compute_logical_xor()
>>> timespans
TimespanList([])
>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans = timespans.compute_logical_xor()
>>> abjad.show(timespans, range_=(0, 10), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((10, 1)))
>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 10),
...         abjad.Timespan(5, 12),
...     ]
... )
>>> abjad.show(timespans, range_=(0, 12), scale=0.5)  
>>> timespans = timespans.compute_logical_xor()
>>> abjad.show(timespans, range_=(0, 12), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((5, 1)))
Timespan(Offset((10, 1)), Offset((12, 1)))
>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 10),
...         abjad.Timespan(5, 12),
...         abjad.Timespan(-2, 2),
...     ]
... )
>>> abjad.show(timespans, range_=(0, 12), scale=0.5)  
>>> timespans = timespans.compute_logical_xor()
>>> abjad.show(timespans, scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((-2, 1)), Offset((0, 1)))
Timespan(Offset((2, 1)), Offset((5, 1)))
Timespan(Offset((10, 1)), Offset((12, 1)))
>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(-2, 2),
...         abjad.Timespan(10, 20),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans = timespans.compute_logical_xor()
>>> abjad.show(timespans, range_=(-2, 20), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((-2, 1)), Offset((2, 1)))
Timespan(Offset((10, 1)), Offset((20, 1)))
>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 10),
...         abjad.Timespan(4, 8),
...         abjad.Timespan(2, 6),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans = timespans.compute_logical_xor()
>>> abjad.show(timespans, range_=(0, 10), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((2, 1)))
Timespan(Offset((8, 1)), Offset((10, 1)))
>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 10),
...         abjad.Timespan(0, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans = timespans.compute_logical_xor()
>>> timespans
TimespanList([])

Operates in place and returns timespan list.

Return type:

TimespanList

compute_overlap_factor(timespan=None)[source]

Computes overlap factor of timespans.

Example timespan list:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 10),
...         abjad.Timespan(5, 15),
...         abjad.Timespan(20, 25),
...         abjad.Timespan(20, 30),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  

Computes overlap factor across the entire list:

>>> timespans.compute_overlap_factor()
Fraction(7, 6)

Computes overlap factor within a specific timespan:

>>> timespans.compute_overlap_factor(timespan=abjad.Timespan(-15, 0))
Fraction(0, 1)

Computes overlap factor:

>>> timespans.compute_overlap_factor(timespan=abjad.Timespan(-10, 5))
Fraction(1, 3)

Computes overlap factor:

>>> timespans.compute_overlap_factor(timespan=abjad.Timespan(-5, 10))
Fraction(1, 1)

Computes overlap factor:

>>> timespans.compute_overlap_factor(timespan=abjad.Timespan(0, 15))
Fraction(4, 3)

Computes overlap factor:

>>> timespans.compute_overlap_factor(timespan=abjad.Timespan(5, 20))
Fraction(1, 1)

Computes overlap factor:

>>> timespans.compute_overlap_factor(timespan=abjad.Timespan(10, 25))
Fraction(1, 1)

Computes overlap factor:

>>> timespans.compute_overlap_factor(timespan=abjad.Timespan(15, 30))
Fraction(1, 1)
Return type:

Fraction

compute_overlap_factor_mapping()[source]

Computes overlap factor for each consecutive offset pair in timespans.

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 10),
...         abjad.Timespan(5, 15),
...         abjad.Timespan(20, 25),
...         abjad.Timespan(20, 30),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> mapping = timespans.compute_overlap_factor_mapping()
>>> for timespan, overlap_factor in mapping.items():
...     timespan.start_offset, timespan.stop_offset, overlap_factor
... 
(Offset((0, 1)), Offset((5, 1)), Fraction(1, 1))
(Offset((5, 1)), Offset((10, 1)), Fraction(2, 1))
(Offset((10, 1)), Offset((15, 1)), Fraction(1, 1))
(Offset((15, 1)), Offset((20, 1)), Fraction(0, 1))
(Offset((20, 1)), Offset((25, 1)), Fraction(2, 1))
(Offset((25, 1)), Offset((30, 1)), Fraction(1, 1))

Returns mapping.

Return type:

dict

(list).copy()

Return a shallow copy of the list.

(list).count(value, /)

Return number of occurrences of value.

count_offsets()[source]

Counts offsets.

Counts offsets:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((3, 1)))
Timespan(Offset((3, 1)), Offset((6, 1)))
Timespan(Offset((6, 1)), Offset((10, 1)))
>>> offset_counter = timespans.count_offsets()
>>> abjad.show(offset_counter, range_=(0, 10), scale=0.5)  
>>> for offset, count in sorted(timespans.count_offsets().items.items()):
...     offset, count
... 
(Offset((0, 1)), 1)
(Offset((3, 1)), 2)
(Offset((6, 1)), 2)
(Offset((10, 1)), 1)

Counts offsets:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 16),
...         abjad.Timespan(5, 12),
...         abjad.Timespan(-2, 8),
...         abjad.Timespan(15, 20),
...         abjad.Timespan(24, 30),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((16, 1)))
Timespan(Offset((5, 1)), Offset((12, 1)))
Timespan(Offset((-2, 1)), Offset((8, 1)))
Timespan(Offset((15, 1)), Offset((20, 1)))
Timespan(Offset((24, 1)), Offset((30, 1)))
>>> offset_counter = timespans.count_offsets()
>>> abjad.show(offset_counter, range_=(0, 30), scale=0.5)  
>>> for offset, count in sorted(timespans.count_offsets().items.items()):
...     offset, count
... 
(Offset((-2, 1)), 1)
(Offset((0, 1)), 1)
(Offset((5, 1)), 1)
(Offset((8, 1)), 1)
(Offset((12, 1)), 1)
(Offset((15, 1)), 1)
(Offset((16, 1)), 1)
(Offset((20, 1)), 1)
(Offset((24, 1)), 1)
(Offset((30, 1)), 1)

Counts offsets:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(0, 6),
...         abjad.Timespan(0, 9),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> offset_counter = timespans.count_offsets()
>>> abjad.show(offset_counter, range_=(0, 9), scale=0.5)  
>>> for offset, count in sorted(timespans.count_offsets().items.items()):
...     offset, count
... 
(Offset((0, 1)), 3)
(Offset((3, 1)), 1)
(Offset((6, 1)), 1)
(Offset((9, 1)), 1)

Returns counter.

explode(inventory_count=None)[source]

Explodes timespans into timespan lists, avoiding overlap, and distributing density as evenly as possible.

Example timespan list:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(5, 13),
...         abjad.Timespan(6, 10),
...         abjad.Timespan(8, 9),
...         abjad.Timespan(15, 23),
...         abjad.Timespan(16, 21),
...         abjad.Timespan(17, 19),
...         abjad.Timespan(19, 20),
...         abjad.Timespan(25, 30),
...         abjad.Timespan(26, 29),
...         abjad.Timespan(32, 34),
...         abjad.Timespan(34, 37),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  

Explodes timespans into the optimal number of non-overlapping timespan_lists:

>>> for exploded_timespan_list in timespans.explode():
...     for _ in exploded_timespan_list:
...         _
...     "---"
... 
Timespan(Offset((0, 1)), Offset((3, 1)))
Timespan(Offset((5, 1)), Offset((13, 1)))
Timespan(Offset((17, 1)), Offset((19, 1)))
Timespan(Offset((19, 1)), Offset((20, 1)))
Timespan(Offset((34, 1)), Offset((37, 1)))
'---'
Timespan(Offset((6, 1)), Offset((10, 1)))
Timespan(Offset((16, 1)), Offset((21, 1)))
Timespan(Offset((25, 1)), Offset((30, 1)))
'---'
Timespan(Offset((8, 1)), Offset((9, 1)))
Timespan(Offset((15, 1)), Offset((23, 1)))
Timespan(Offset((26, 1)), Offset((29, 1)))
Timespan(Offset((32, 1)), Offset((34, 1)))
'---'

Explodes timespans into a less-than-optimal number of overlapping timespan_lists:

>>> for exploded_timespan_list in timespans.explode(inventory_count=6):
...     for _ in exploded_timespan_list:
...         _
...     "---"
... 
Timespan(Offset((16, 1)), Offset((21, 1)))
Timespan(Offset((34, 1)), Offset((37, 1)))
'---'
Timespan(Offset((15, 1)), Offset((23, 1)))
'---'
Timespan(Offset((8, 1)), Offset((9, 1)))
Timespan(Offset((17, 1)), Offset((19, 1)))
Timespan(Offset((19, 1)), Offset((20, 1)))
Timespan(Offset((26, 1)), Offset((29, 1)))
'---'
Timespan(Offset((6, 1)), Offset((10, 1)))
Timespan(Offset((32, 1)), Offset((34, 1)))
'---'
Timespan(Offset((5, 1)), Offset((13, 1)))
'---'
Timespan(Offset((0, 1)), Offset((3, 1)))
Timespan(Offset((25, 1)), Offset((30, 1)))
'---'
Return type:

tuple[TimespanList, ...]

overridden extend(items)[source]

Coerces items and extends.

get_timespan_that_satisfies_time_relation(time_relation)[source]

Gets timespan that satisifies time_relation.

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespan = abjad.Timespan(2, 5)
>>> time_relation = (
...     lambda _: timespan.start_offset < _.start_offset < timespan.stop_offset
... )
>>> timespan = timespans.get_timespan_that_satisfies_time_relation(time_relation)
>>> abjad.show(timespan, range_=(0, 10), scale=0.5)  
>>> timespan
Timespan(Offset((3, 1)), Offset((6, 1)))

Returns timespan when timespan list contains exactly one timespan that satisfies time_relation.

Raises exception when timespan list contains no timespan that satisfies time_relation.

Raises exception when timespan list contains more than one timespan that satisfies time_relation.

get_timespans_that_satisfy_time_relation(time_relation)[source]

Gets timespans that satisfy time_relation.

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespan = abjad.Timespan(2, 8)
>>> time_relation = (
...     lambda _: timespan.start_offset < _.start_offset < timespan.stop_offset
... )
>>> timespans = timespans.get_timespans_that_satisfy_time_relation(time_relation)
>>> abjad.show(timespans, range_=(0, 10), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((3, 1)), Offset((6, 1)))
Timespan(Offset((6, 1)), Offset((10, 1)))
Return type:

TimespanList

has_timespan_that_satisfies_time_relation(time_relation)[source]

Is true when list has matching timespan.

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespan = abjad.Timespan(2, 8)
>>> time_relation = (
...     lambda _: timespan.start_offset < _.start_offset < timespan.stop_offset
... )
>>> timespans.has_timespan_that_satisfies_time_relation(time_relation)
True

Is false when list does not have matching timespan:

>>> timespan = abjad.Timespan(10, 20)
>>> timespans.has_timespan_that_satisfies_time_relation(time_relation)
False
Return type:

bool

(list).index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

(list).insert(index, object, /)

Insert object before index.

partition(include_tangent_timespans=False)[source]

Partitions timespans into timespan lists.

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((3, 1)))
Timespan(Offset((3, 1)), Offset((6, 1)))
Timespan(Offset((6, 1)), Offset((10, 1)))
>>> for timespan_list in timespans.partition():
...     for _ in timespan_list:
...         _
...     "---"
... 
Timespan(Offset((0, 1)), Offset((3, 1)))
'---'
Timespan(Offset((3, 1)), Offset((6, 1)))
'---'
Timespan(Offset((6, 1)), Offset((10, 1)))
'---'

Partitions timespans:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 16),
...         abjad.Timespan(5, 12),
...         abjad.Timespan(-2, 8),
...         abjad.Timespan(15, 20),
...         abjad.Timespan(24, 30),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((16, 1)))
Timespan(Offset((5, 1)), Offset((12, 1)))
Timespan(Offset((-2, 1)), Offset((8, 1)))
Timespan(Offset((15, 1)), Offset((20, 1)))
Timespan(Offset((24, 1)), Offset((30, 1)))
>>> for timespan_list in timespans.partition():
...     for _ in timespan_list:
...         _
...     "---"
... 
Timespan(Offset((-2, 1)), Offset((8, 1)))
Timespan(Offset((0, 1)), Offset((16, 1)))
Timespan(Offset((5, 1)), Offset((12, 1)))
Timespan(Offset((15, 1)), Offset((20, 1)))
'---'
Timespan(Offset((24, 1)), Offset((30, 1)))
'---'

Treats tangent timespans as part of the same group when include_tangent_timespans is true:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> for timespan_list in timespans.partition(
...     include_tangent_timespans=True,
... ):
...     for _ in timespan_list:
...         _
...     "---"
... 
Timespan(Offset((0, 1)), Offset((3, 1)))
Timespan(Offset((3, 1)), Offset((6, 1)))
Timespan(Offset((6, 1)), Offset((10, 1)))
'---'

Returns zero or more timespan_lists.

Return type:

tuple[TimespanList, ...]

(list).pop(index=-1, /)

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

reflect(axis=None)[source]

Reflects timespans.

Reflects timespans about timespan list axis:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans = timespans.reflect()
>>> abjad.show(timespans, scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((4, 1)))
Timespan(Offset((4, 1)), Offset((7, 1)))
Timespan(Offset((7, 1)), Offset((10, 1)))

Reflects timespans about arbitrary axis:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, range_=(0, 30), scale=0.5)  
>>> timespans = timespans.reflect(axis=abjad.Offset(15))
>>> abjad.show(timespans, range_=(0, 30), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((20, 1)), Offset((24, 1)))
Timespan(Offset((24, 1)), Offset((27, 1)))
Timespan(Offset((27, 1)), Offset((30, 1)))

Operates in place and returns timespan list.

Return type:

TimespanList

overridden remove(item)[source]

Coerces item and removes.

remove_degenerate_timespans()[source]

Removes degenerate timespans.

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(5, 5),
...         abjad.Timespan(5, 10),
...         abjad.Timespan(5, 25),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans = timespans.remove_degenerate_timespans()
>>> abjad.show(timespans, scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((5, 1)), Offset((10, 1)))
Timespan(Offset((5, 1)), Offset((25, 1)))

Operates in place and returns timespan list.

Return type:

TimespanList

repeat_to_stop_offset(stop_offset)[source]

Repeats timespans to stop_offset.

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, range_=(0, 15), scale=0.5)  
>>> timespans = timespans.repeat_to_stop_offset(15)
>>> abjad.show(timespans, range_=(0, 15), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((3, 1)))
Timespan(Offset((3, 1)), Offset((6, 1)))
Timespan(Offset((6, 1)), Offset((10, 1)))
Timespan(Offset((10, 1)), Offset((13, 1)))
Timespan(Offset((13, 1)), Offset((15, 1)))

Operates in place and returns timespan list.

Return type:

TimespanList

(list).reverse()

Reverse IN PLACE.

rotate(count)[source]

Rotates by count contiguous timespans.

Rotates by one timespan to the left:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 4),
...         abjad.Timespan(4, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans = timespans.rotate(-1)
>>> abjad.show(timespans, scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((1, 1)))
Timespan(Offset((1, 1)), Offset((7, 1)))
Timespan(Offset((7, 1)), Offset((10, 1)))

Rotates by one timespan to the right:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 4),
...         abjad.Timespan(4, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans = timespans.rotate(1)
>>> abjad.show(timespans, scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((6, 1)))
Timespan(Offset((6, 1)), Offset((9, 1)))
Timespan(Offset((9, 1)), Offset((10, 1)))

Operates in place and returns timespan list.

Return type:

TimespanList

round_offsets(multiplier, anchor=Horizontal.LEFT, must_be_wellformed=True)[source]

Rounds offsets of timespans in list to multiples of multiplier.

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 2),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> rounded_timespans = timespans.round_offsets(3)
>>> abjad.show(rounded_timespans, range_=(0, 10), scale=0.5)  
>>> for _ in rounded_timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((3, 1)))
Timespan(Offset((3, 1)), Offset((6, 1)))
Timespan(Offset((6, 1)), Offset((9, 1)))
>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 2),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> rounded_timespans = timespans.round_offsets(5)
>>> abjad.show(rounded_timespans, scale=0.5)  
>>> for _ in rounded_timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((5, 1)))
Timespan(Offset((5, 1)), Offset((10, 1)))
Timespan(Offset((5, 1)), Offset((10, 1)))
>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 2),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, range_=(-5, 10), scale=0.5)  
>>> rounded_timespans = timespans.round_offsets(
...     5,
...     anchor=abjad.RIGHT,
... )
>>> abjad.show(rounded_timespans, range_=(-5, 10), scale=0.5)  
>>> for _ in rounded_timespans:
...     _
... 
Timespan(Offset((-5, 1)), Offset((0, 1)))
Timespan(Offset((0, 1)), Offset((5, 1)))
Timespan(Offset((5, 1)), Offset((10, 1)))
>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 2),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> rounded_timespans = timespans.round_offsets(
...     5,
...     anchor=abjad.RIGHT,
...     must_be_wellformed=False,
... )
>>> for _ in rounded_timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((0, 1)))
Timespan(Offset((5, 1)), Offset((5, 1)))
Timespan(Offset((5, 1)), Offset((10, 1)))

Operates in place and returns timespan list.

Return type:

TimespanList

scale(multiplier, anchor=Horizontal.LEFT)[source]

Scales timespan by multiplier relative to anchor.

Scales timespans relative to timespan list start offset:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, range_=(0, 14), scale=0.5)  
>>> timespans = timespans.scale(2)
>>> abjad.show(timespans, range_=(0, 14), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((6, 1)))
Timespan(Offset((3, 1)), Offset((9, 1)))
Timespan(Offset((6, 1)), Offset((14, 1)))

Scales timespans relative to timespan list stop offset:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, range_=(-3, 10), scale=0.5)  
>>> timespans = timespans.scale(2, anchor=abjad.RIGHT)
>>> abjad.show(timespans, range_=(-3, 10), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((-3, 1)), Offset((3, 1)))
Timespan(Offset((0, 1)), Offset((6, 1)))
Timespan(Offset((2, 1)), Offset((10, 1)))

Operates in place and returns timespan list.

Return type:

TimespanList

(list).sort(*, key=None, reverse=False)

Sort the list in ascending order and return None.

The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).

If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.

The reverse flag can be set to sort in descending order.

split_at_offset(offset)[source]

Splits timespans at offset.

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> left, right = timespans.split_at_offset(4)
>>> abjad.show(left, range_=(0, 10), scale=0.5)  
>>> for _ in left:
...     _
... 
Timespan(Offset((0, 1)), Offset((3, 1)))
Timespan(Offset((3, 1)), Offset((4, 1)))
>>> abjad.show(right, range_=(0, 10), scale=0.5)  
>>> for _ in right:
...     _
... 
Timespan(Offset((4, 1)), Offset((6, 1)))
Timespan(Offset((6, 1)), Offset((10, 1)))

Splits at offset:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> left, right = timespans.split_at_offset(6)
>>> abjad.show(left, range_=(0, 10), scale=0.5)  
>>> for _ in left:
...     _
... 
Timespan(Offset((0, 1)), Offset((3, 1)))
Timespan(Offset((3, 1)), Offset((6, 1)))
>>> abjad.show(right, range_=(0, 10), scale=0.5)  
>>> for _ in right:
...     _
... 
Timespan(Offset((6, 1)), Offset((10, 1)))

Splits at offset:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> left, right = timespans.split_at_offset(-1)
>>> left
TimespanList([])
>>> abjad.show(right, range_=(0, 10), scale=0.5)  
>>> for _ in right:
...     _
... 
Timespan(Offset((0, 1)), Offset((3, 1)))
Timespan(Offset((3, 1)), Offset((6, 1)))
Timespan(Offset((6, 1)), Offset((10, 1)))
Return type:

tuple[TimespanList, TimespanList]

split_at_offsets(offsets)[source]

Splits timespans at offsets.

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(4, 10),
...         abjad.Timespan(15, 20),
...     ]
... )
>>> abjad.show(timespans, range_=(0, 20), scale=0.5)  
>>> offsets = [-1, 3, 6, 12, 13]
>>> for timespan_list in timespans.split_at_offsets(offsets):
...     abjad.show(timespan_list, range_=(0, 20), scale=0.5)  
...     for _ in timespan_list:
...         _
...     "---"
... 
Timespan(Offset((0, 1)), Offset((3, 1)))
'---'
Timespan(Offset((3, 1)), Offset((6, 1)))
Timespan(Offset((4, 1)), Offset((6, 1)))
'---'
Timespan(Offset((6, 1)), Offset((10, 1)))
'---'
Timespan(Offset((15, 1)), Offset((20, 1)))
'---'

Splits empty list:

>>> timespans = abjad.TimespanList([])
>>> timespans.split_at_offsets(offsets)
[TimespanList([])]
Return type:

list[TimespanList]

stretch(multiplier, anchor=None)[source]

Stretches timespans by multiplier relative to anchor.

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, range_=(0, 20), scale=0.5)  
>>> timespans = timespans.stretch(2)
>>> abjad.show(timespans, scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((6, 1)))
Timespan(Offset((6, 1)), Offset((12, 1)))
Timespan(Offset((12, 1)), Offset((20, 1)))

Stretches timespans relative to arbitrary anchor:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, range_=(-8, 12), scale=0.5)  
>>> timespans = timespans.stretch(2, anchor=abjad.Offset(8))
>>> abjad.show(timespans, scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((-8, 1)), Offset((-2, 1)))
Timespan(Offset((-2, 1)), Offset((4, 1)))
Timespan(Offset((4, 1)), Offset((12, 1)))

Operates in place and returns timespan list.

Return type:

TimespanList

translate(translation=None)[source]

Translates timespans by translation.

Translates timespan by offset 50:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, range_=(0, 60), scale=0.5)  
>>> timespans = timespans.translate(50)
>>> abjad.show(timespans, range_=(0, 60), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((50, 1)), Offset((53, 1)))
Timespan(Offset((53, 1)), Offset((56, 1)))
Timespan(Offset((56, 1)), Offset((60, 1)))

Operates in place and returns timespan list.

Return type:

TimespanList

translate_offsets(start_offset_translation=None, stop_offset_translation=None)[source]

Translates timespans by start_offset_translation and stop_offset_translation.

Translates timespan start- and stop-offsets equally:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, range_=(0, 60), scale=0.5)  
>>> timespans = timespans.translate_offsets(50, 50)
>>> abjad.show(timespans, range_=(0, 60), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((50, 1)), Offset((53, 1)))
Timespan(Offset((53, 1)), Offset((56, 1)))
Timespan(Offset((56, 1)), Offset((60, 1)))

Translates timespan stop-offsets only:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, range_=(0, 30), scale=0.5)  
>>> timespans = timespans.translate_offsets(stop_offset_translation=20)
>>> abjad.show(timespans, range_=(0, 30), scale=0.5)  
>>> for _ in timespans:
...     _
... 
Timespan(Offset((0, 1)), Offset((23, 1)))
Timespan(Offset((3, 1)), Offset((26, 1)))
Timespan(Offset((6, 1)), Offset((30, 1)))

Operates in place and returns timespan list.

Return type:

TimespanList


Read-only properties

all_are_contiguous

Is true when all timespans are contiguous.

Is true when all timespans are contiguous:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans.all_are_contiguous
True

Is false when timespans not contiguous:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 16),
...         abjad.Timespan(5, 12),
...         abjad.Timespan(-2, 8),
...         abjad.Timespan(15, 20),
...         abjad.Timespan(24, 30),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans.all_are_contiguous
False

Is true when timespan list is empty:

>>> abjad.TimespanList().all_are_contiguous
True
all_are_nonoverlapping

Is true when all timespans are nonoverlapping.

Is true when all timespans are nonoverlapping:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans.all_are_nonoverlapping
True

Is false when timespans are overlapping:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 16),
...         abjad.Timespan(5, 12),
...         abjad.Timespan(-2, 8),
...         abjad.Timespan(15, 20),
...         abjad.Timespan(24, 30),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans.all_are_nonoverlapping
False

Is true when timespan list is empty:

>>> abjad.TimespanList().all_are_nonoverlapping
True
all_are_wellformed

Is true when all timespans are wellformed.

Is true when all timespans are wellformed:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans.all_are_wellformed
True

Is true when all timespans are wellformed:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 16),
...         abjad.Timespan(5, 12),
...         abjad.Timespan(-2, 8),
...         abjad.Timespan(15, 20),
...         abjad.Timespan(24, 30),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans.all_are_wellformed
True

Is true when timespan list is empty:

>>> abjad.TimespanList().all_are_wellformed
True

Is false when timespans are not all wellformed.

axis

Gets axis defined equal to arithmetic mean of start- and stop-offsets.

Gets axis:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans.axis
Offset((5, 1))

Gets axis:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 16),
...         abjad.Timespan(5, 12),
...         abjad.Timespan(-2, 8),
...         abjad.Timespan(15, 20),
...         abjad.Timespan(24, 30),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans.axis
Offset((14, 1))

Gets none when timespan list is empty:

>>> abjad.TimespanList().axis is None
True
duration

Gets duration of timespan list.

Gets duration:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans.duration
Duration(10, 1)

Gets duration:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 16),
...         abjad.Timespan(5, 12),
...         abjad.Timespan(-2, 8),
...         abjad.Timespan(15, 20),
...         abjad.Timespan(24, 30),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans.duration
Duration(32, 1)

Gets zero when timespan list is empty:

>>> abjad.TimespanList().duration
Duration(0, 1)
is_sorted

Is true when timespans are in time order.

Is true when timespans are sorted:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans.is_sorted
True

Is false when timespans are not sorted:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(6, 10),
...         abjad.Timespan(3, 6),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans.is_sorted
False
start_offset

Gets start offset.

Defined equal to earliest start offset of any timespan in list.

Gets start offset:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans.start_offset
Offset((0, 1))

Gets start offset:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 16),
...         abjad.Timespan(5, 12),
...         abjad.Timespan(-2, 8),
...         abjad.Timespan(15, 20),
...         abjad.Timespan(24, 30),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans.start_offset
Offset((-2, 1))

Gets negative infinity when timespan list is empty:

>>> abjad.TimespanList().start_offset
NegativeInfinity()
stop_offset

Gets stop offset.

Defined equal to latest stop offset of any timespan.

Gets stop offset:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans.stop_offset
Offset((10, 1))

Gets stop offset:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 16),
...         abjad.Timespan(5, 12),
...         abjad.Timespan(-2, 8),
...         abjad.Timespan(15, 20),
...         abjad.Timespan(24, 30),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> timespans.stop_offset
Offset((30, 1))

Gets infinity when timespan list is empty:

>>> abjad.TimespanList().stop_offset
Infinity()
timespan

Gets timespan of timespan list.

Gets timespan:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 3),
...         abjad.Timespan(3, 6),
...         abjad.Timespan(6, 10),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> abjad.show(timespans.timespan, range_=(0, 10), scale=0.5)  
>>> timespans.timespan
Timespan(Offset((0, 1)), Offset((10, 1)))

Gets timespan:

>>> timespans = abjad.TimespanList(
...     [
...         abjad.Timespan(0, 16),
...         abjad.Timespan(5, 12),
...         abjad.Timespan(-2, 8),
...         abjad.Timespan(15, 20),
...         abjad.Timespan(24, 30),
...     ]
... )
>>> abjad.show(timespans, scale=0.5)  
>>> abjad.show(timespans.timespan, range_=(0, 30), scale=0.5)  
>>> timespans.timespan
Timespan(Offset((-2, 1)), Offset((30, 1)))

Gets infinite timespan when list is empty:

>>> abjad.TimespanList().timespan
Timespan(NegativeInfinity(), Infinity())

Returns timespan.