Timespan

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.system" { graph [label="abjad.system"]; node [color=1]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/timespans/../system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; "abjad.system.AbjadValueObject.AbjadValueObject" [URL="../api/abjad/timespans/../system/AbjadValueObject.html#abjad.system.AbjadValueObject.AbjadValueObject", label="Abjad\nValue\nObject", target=_top]; "abjad.system.AbjadObject.AbjadObject" -> "abjad.system.AbjadValueObject.AbjadValueObject"; } subgraph "cluster_abjad.timespans" { graph [label="abjad.timespans"]; node [color=2]; "abjad.timespans.AnnotatedTimespan.AnnotatedTimespan" [URL="../api/abjad/timespans/AnnotatedTimespan.html#abjad.timespans.AnnotatedTimespan.AnnotatedTimespan", label="Annotated\nTimespan", target=_top]; "abjad.timespans.Timespan.Timespan" [URL="../api/abjad/timespans/Timespan.html#abjad.timespans.Timespan.Timespan", color=black, fontcolor=white, label=Timespan, target=_top]; "abjad.timespans.Timespan.Timespan" -> "abjad.timespans.AnnotatedTimespan.AnnotatedTimespan"; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } "abjad.system.AbjadValueObject.AbjadValueObject" -> "abjad.timespans.Timespan.Timespan"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjad.timespans.Timespan.Timespan(start_offset=NegativeInfinity, stop_offset=Infinity)

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)

Timespans are closed-open intervals.

Timespans are immutable.


Attributes Summary

__and__ Logical AND of two timespans.
__eq__ Is true when argument is a timespan with equal offsets.
__format__ Formats timespan.
__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__ Hashes timespan.
__illustrate__ Illustrates timespan.
__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.
__sub__ Subtract argument from timespan.
__xor__ Logical XOR of two timespans.
axis Arithmetic mean of timespan start- and stop-offsets.
contains_timespan_improperly Is true when timespan contains timespan improperly.
curtails_timespan Is true when timespan curtails timespan.
delays_timespan Is true when timespan delays timespan.
divide_by_ratio Divides timespan by ratio.
duration Duration of timespan.
get_overlap_with_timespan Gets duration of overlap with timespan.
happens_during_timespan Is true when timespan happens during timespan.
intersects_timespan Is true when timespan intersects timespan.
is_congruent_to_timespan Is true when timespan is congruent to timespan.
is_tangent_to_timespan Is true when timespan is tangent to timespan.
is_well_formed Is true when timespan start offset preceeds timespan stop offset.
offsets Timespan offsets.
overlaps_all_of_timespan Is true when timespan overlaps all of timespan.
overlaps_only_start_of_timespan Is true when timespan overlaps only start of timespan.
overlaps_only_stop_of_timespan Is true when timespan overlaps only stop of timespan.
overlaps_start_of_timespan Is true when timespan overlaps start of timespan.
overlaps_stop_of_timespan Is true when timespan overlaps start of timespan.
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:
start_offset Timespan start offset.
starts_after_offset Is true when timespan overlaps start of timespan.
starts_after_timespan_starts Is true when timespan starts after timespan starts.
starts_after_timespan_stops Is true when timespan starts after timespan stops.
starts_at_offset Is true when timespan starts at offset.
starts_at_or_after_offset Is true when timespan starts at or after offset.
starts_before_offset Is true when timespan starts before offset.
starts_before_or_at_offset Is true when timespan starts before or at offset.
starts_before_timespan_starts Is true when timespan starts before timespan starts.
starts_before_timespan_stops Is true when timespan starts before timespan stops.
starts_during_timespan Is true when timespan starts during timespan.
starts_when_timespan_starts Is true when timespan starts when timespan starts.
starts_when_timespan_stops Is true when timespan starts when timespan stops.
stop_offset Timespan stop offset.
stops_after_offset Is true when timespan stops after offset.
stops_after_timespan_starts Is true when timespan stops when timespan starts.
stops_after_timespan_stops Is true when timespan stops when timespan stops.
stops_at_offset Is true when timespan stops at offset.
stops_at_or_after_offset Is true when timespan stops at or after offset.
stops_before_offset Is true when timespan stops before offset.
stops_before_or_at_offset Is true when timespan stops before or at offset.
stops_before_timespan_starts Is true when timespan stops before timespan starts.
stops_before_timespan_stops Is true when timespan stops before timespan stops.
stops_during_timespan Is true when timespan stops during timespan.
stops_when_timespan_starts Is true when timespan stops when timespan starts.
stops_when_timespan_stops Is true when timespan stops when timespan stops.
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.
trisects_timespan Is true when timespan trisects timespan.

Special methods

__and__(argument)

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(start_offset=Offset(5, 1), stop_offset=Offset(10, 1))])
>>> timespan_1 & timespan_3
TimespanList([Timespan(start_offset=Offset(0, 1), stop_offset=Offset(2, 1))])
>>> timespan_1 & timespan_4
TimespanList([])
>>> timespan_2 & timespan_3
TimespanList([])
>>> timespan_2 & timespan_4
TimespanList([Timespan(start_offset=Offset(10, 1), stop_offset=Offset(12, 1))])
>>> timespan_3 & timespan_4
TimespanList([])

Returns timespan list.

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

__eq__(argument)

Is true when argument is a timespan with equal offsets.

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

Returns true or false.

__format__(format_specification='')

Formats timespan.

>>> timespan = abjad.Timespan(0, 10)
>>> abjad.f(timespan)
abjad.Timespan(
    start_offset=abjad.Offset(0, 1),
    stop_offset=abjad.Offset(10, 1),
    )

Returns string.

__ge__(argument)

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

Returns true or false.

__gt__(argument)

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

Returns true or false.

__hash__()

Hashes timespan.

Required to be explicitly redefined on Python 3 if __eq__ changes.

Returns integer.

__illustrate__(range_=None, scale=None)

Illustrates timespan.

Returns LilyPond file.

__le__(argument)

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

Returns true or false.

__len__()

Defined equal to 1 for all timespans.

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

Returns positive integer.

__lt__(argument)

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

Returns true or false.

__or__(argument)

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)
>>> new_timespan = timespan_1 | timespan_2
>>> abjad.f(new_timespan)
abjad.TimespanList(
    [
        abjad.Timespan(
            start_offset=abjad.Offset(0, 1),
            stop_offset=abjad.Offset(12, 1),
            ),
        ]
    )
>>> new_timespan = timespan_1 | timespan_3
>>> abjad.f(new_timespan)
abjad.TimespanList(
    [
        abjad.Timespan(
            start_offset=abjad.Offset(-2, 1),
            stop_offset=abjad.Offset(10, 1),
            ),
        ]
    )
>>> new_timespan = timespan_1 | timespan_4
>>> abjad.f(new_timespan)
abjad.TimespanList(
    [
        abjad.Timespan(
            start_offset=abjad.Offset(0, 1),
            stop_offset=abjad.Offset(20, 1),
            ),
        ]
    )
>>> new_timespan = timespan_2 | timespan_3
>>> abjad.f(new_timespan)
abjad.TimespanList(
    [
        abjad.Timespan(
            start_offset=abjad.Offset(-2, 1),
            stop_offset=abjad.Offset(2, 1),
            ),
        abjad.Timespan(
            start_offset=abjad.Offset(5, 1),
            stop_offset=abjad.Offset(12, 1),
            ),
        ]
    )
>>> new_timespan = timespan_2 | timespan_4
>>> abjad.f(new_timespan)
abjad.TimespanList(
    [
        abjad.Timespan(
            start_offset=abjad.Offset(5, 1),
            stop_offset=abjad.Offset(20, 1),
            ),
        ]
    )
>>> new_timespan = timespan_3 | timespan_4
>>> abjad.f(new_timespan)
abjad.TimespanList(
    [
        abjad.Timespan(
            start_offset=abjad.Offset(-2, 1),
            stop_offset=abjad.Offset(2, 1),
            ),
        abjad.Timespan(
            start_offset=abjad.Offset(10, 1),
            stop_offset=abjad.Offset(20, 1),
            ),
        ]
    )

Returns timespan list.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

__sub__(argument)

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(start_offset=Offset(0, 1), stop_offset=Offset(5, 1))])
>>> timespan_1 - timespan_3
TimespanList([Timespan(start_offset=Offset(2, 1), stop_offset=Offset(10, 1))])
>>> timespan_1 - timespan_4
TimespanList([Timespan(start_offset=Offset(0, 1), stop_offset=Offset(10, 1))])
>>> timespan_2 - timespan_1
TimespanList([Timespan(start_offset=Offset(10, 1), stop_offset=Offset(12, 1))])
>>> timespan_2 - timespan_2
TimespanList([])
>>> timespan_2 - timespan_3
TimespanList([Timespan(start_offset=Offset(5, 1), stop_offset=Offset(12, 1))])
>>> timespan_2 - timespan_4
TimespanList([Timespan(start_offset=Offset(5, 1), stop_offset=Offset(10, 1))])
>>> timespan_3 - timespan_3
TimespanList([])
>>> timespan_3 - timespan_1
TimespanList([Timespan(start_offset=Offset(-2, 1), stop_offset=Offset(0, 1))])
>>> timespan_3 - timespan_2
TimespanList([Timespan(start_offset=Offset(-2, 1), stop_offset=Offset(2, 1))])
>>> timespan_3 - timespan_4
TimespanList([Timespan(start_offset=Offset(-2, 1), stop_offset=Offset(2, 1))])
>>> timespan_4 - timespan_4
TimespanList([])
>>> timespan_4 - timespan_1
TimespanList([Timespan(start_offset=Offset(10, 1), stop_offset=Offset(20, 1))])
>>> timespan_4 - timespan_2
TimespanList([Timespan(start_offset=Offset(12, 1), stop_offset=Offset(20, 1))])
>>> timespan_4 - timespan_3
TimespanList([Timespan(start_offset=Offset(10, 1), stop_offset=Offset(20, 1))])

Returns timespan list.

__xor__(argument)

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)
>>> new_timespan = timespan_1 ^ timespan_2
>>> abjad.f(new_timespan)
abjad.TimespanList(
    [
        abjad.Timespan(
            start_offset=abjad.Offset(0, 1),
            stop_offset=abjad.Offset(5, 1),
            ),
        abjad.Timespan(
            start_offset=abjad.Offset(10, 1),
            stop_offset=abjad.Offset(12, 1),
            ),
        ]
    )
>>> new_timespan = timespan_1 ^ timespan_3
>>> abjad.f(new_timespan)
abjad.TimespanList(
    [
        abjad.Timespan(
            start_offset=abjad.Offset(-2, 1),
            stop_offset=abjad.Offset(0, 1),
            ),
        abjad.Timespan(
            start_offset=abjad.Offset(2, 1),
            stop_offset=abjad.Offset(10, 1),
            ),
        ]
    )
>>> new_timespan = timespan_1 ^ timespan_4
>>> abjad.f(new_timespan)
abjad.TimespanList(
    [
        abjad.Timespan(
            start_offset=abjad.Offset(0, 1),
            stop_offset=abjad.Offset(10, 1),
            ),
        abjad.Timespan(
            start_offset=abjad.Offset(10, 1),
            stop_offset=abjad.Offset(20, 1),
            ),
        ]
    )
>>> new_timespan = timespan_2 ^ timespan_3
>>> abjad.f(new_timespan)
abjad.TimespanList(
    [
        abjad.Timespan(
            start_offset=abjad.Offset(-2, 1),
            stop_offset=abjad.Offset(2, 1),
            ),
        abjad.Timespan(
            start_offset=abjad.Offset(5, 1),
            stop_offset=abjad.Offset(12, 1),
            ),
        ]
    )
>>> new_timespan = timespan_2 ^ timespan_4
>>> abjad.f(new_timespan)
abjad.TimespanList(
    [
        abjad.Timespan(
            start_offset=abjad.Offset(5, 1),
            stop_offset=abjad.Offset(10, 1),
            ),
        abjad.Timespan(
            start_offset=abjad.Offset(12, 1),
            stop_offset=abjad.Offset(20, 1),
            ),
        ]
    )
>>> new_timespan = timespan_3 ^ timespan_4
>>> abjad.f(new_timespan)
abjad.TimespanList(
    [
        abjad.Timespan(
            start_offset=abjad.Offset(-2, 1),
            stop_offset=abjad.Offset(2, 1),
            ),
        abjad.Timespan(
            start_offset=abjad.Offset(10, 1),
            stop_offset=abjad.Offset(20, 1),
            ),
        ]
    )

Returns timespan list.


Methods

contains_timespan_improperly(timespan)

Is true when timespan contains timespan improperly.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 10)
>>> timespan_1.contains_timespan_improperly(timespan_1)
True
>>> timespan_1.contains_timespan_improperly(timespan_2)
True
>>> timespan_2.contains_timespan_improperly(timespan_1)
False
>>> timespan_2.contains_timespan_improperly(timespan_2)
True

Returns true or false.

curtails_timespan(timespan)

Is true when timespan curtails timespan.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 10)
>>> timespan_1.curtails_timespan(timespan_1)
False
>>> timespan_1.curtails_timespan(timespan_2)
False
>>> timespan_2.curtails_timespan(timespan_1)
True
>>> timespan_2.curtails_timespan(timespan_2)
False

Returns true or false.

delays_timespan(timespan)

Is true when timespan delays timespan.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 15)
>>> timespan_3 = abjad.Timespan(10, 20)
>>> timespan_1.delays_timespan(timespan_2)
True
>>> timespan_2.delays_timespan(timespan_3)
True

Returns true or false.

divide_by_ratio(ratio)

Divides timespan by ratio.

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

Returns tuple of newly constructed timespans.

get_overlap_with_timespan(timespan)

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)

Returns duration.

happens_during_timespan(timespan)

Is true when timespan happens during timespan.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 10)
>>> timespan_1.happens_during_timespan(timespan_1)
True
>>> timespan_1.happens_during_timespan(timespan_2)
False
>>> timespan_2.happens_during_timespan(timespan_1)
True
>>> timespan_2.happens_during_timespan(timespan_2)
True

Returns true or false.

intersects_timespan(timespan)

Is true when timespan intersects timespan.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 15)
>>> timespan_3 = abjad.Timespan(10, 15)
>>> timespan_1.intersects_timespan(timespan_1)
True
>>> timespan_1.intersects_timespan(timespan_2)
True
>>> timespan_1.intersects_timespan(timespan_3)
False

Returns true or false.

is_congruent_to_timespan(timespan)

Is true when timespan is congruent to timespan.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 15)
>>> timespan_1.is_congruent_to_timespan(timespan_1)
True
>>> timespan_1.is_congruent_to_timespan(timespan_2)
False
>>> timespan_2.is_congruent_to_timespan(timespan_1)
False
>>> timespan_2.is_congruent_to_timespan(timespan_2)
True

Returns true or false.

is_tangent_to_timespan(timespan)

Is true when timespan is tangent to timespan.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(10, 20)
>>> timespan_1.is_tangent_to_timespan(timespan_1)
False
>>> timespan_1.is_tangent_to_timespan(timespan_2)
True
>>> timespan_2.is_tangent_to_timespan(timespan_1)
True
>>> timespan_2.is_tangent_to_timespan(timespan_2)
False

Returns true or false.

overlaps_all_of_timespan(timespan)

Is true when timespan overlaps all of timespan.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 6)
>>> timespan_3 = abjad.Timespan(5, 10)
>>> timespan_1.overlaps_all_of_timespan(timespan_1)
False
>>> timespan_1.overlaps_all_of_timespan(timespan_2)
True
>>> timespan_1.overlaps_all_of_timespan(timespan_3)
False

Returns true or false.

overlaps_only_start_of_timespan(timespan)

Is true when timespan overlaps only start of timespan.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(-5, 5)
>>> timespan_3 = abjad.Timespan(4, 6)
>>> timespan_4 = abjad.Timespan(5, 15)
>>> timespan_1.overlaps_only_start_of_timespan(timespan_1)
False
>>> timespan_1.overlaps_only_start_of_timespan(timespan_2)
False
>>> timespan_1.overlaps_only_start_of_timespan(timespan_3)
False
>>> timespan_1.overlaps_only_start_of_timespan(timespan_4)
True

Returns true or false.

overlaps_only_stop_of_timespan(timespan)

Is true when timespan overlaps only stop of timespan.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(-5, 5)
>>> timespan_3 = abjad.Timespan(4, 6)
>>> timespan_4 = abjad.Timespan(5, 15)
>>> timespan_1.overlaps_only_stop_of_timespan(timespan_1)
False
>>> timespan_1.overlaps_only_stop_of_timespan(timespan_2)
True
>>> timespan_1.overlaps_only_stop_of_timespan(timespan_3)
False
>>> timespan_1.overlaps_only_stop_of_timespan(timespan_4)
False

Returns true or false.

overlaps_start_of_timespan(timespan)

Is true when timespan overlaps start of timespan.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(-5, 5)
>>> timespan_3 = abjad.Timespan(4, 6)
>>> timespan_4 = abjad.Timespan(5, 15)
>>> timespan_1.overlaps_start_of_timespan(timespan_1)
False
>>> timespan_1.overlaps_start_of_timespan(timespan_2)
False
>>> timespan_1.overlaps_start_of_timespan(timespan_3)
True
>>> timespan_1.overlaps_start_of_timespan(timespan_4)
True

Returns true or false.

overlaps_stop_of_timespan(timespan)

Is true when timespan overlaps start of timespan.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(-5, 5)
>>> timespan_3 = abjad.Timespan(4, 6)
>>> timespan_4 = abjad.Timespan(5, 15)
>>> timespan_1.overlaps_stop_of_timespan(timespan_1)
False
>>> timespan_1.overlaps_stop_of_timespan(timespan_2)
True
>>> timespan_1.overlaps_stop_of_timespan(timespan_3)
True
>>> timespan_1.overlaps_stop_of_timespan(timespan_4)
False

Returns true or false.

reflect(axis=None)

Reflects timespan about axis.

Reverse timespan about timespan axis:

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

Reverse timespan about arbitrary axis:

>>> abjad.Timespan(3, 6).reflect(axis=abjad.Offset(10))
Timespan(start_offset=Offset(14, 1), stop_offset=Offset(17, 1))

Returns new timespan.

round_offsets(multiplier, anchor=Left, must_be_well_formed=True)

Rounds timespan offsets to multiple of multiplier.

>>> timespan = abjad.Timespan((1, 5), (4, 5))
>>> timespan.round_offsets(1)
Timespan(start_offset=Offset(0, 1), stop_offset=Offset(1, 1))
>>> timespan.round_offsets(2)
Timespan(start_offset=Offset(0, 1), stop_offset=Offset(2, 1))
>>> timespan.round_offsets(
...     2,
...     anchor=abjad.Right,
...     )
Timespan(start_offset=Offset(-2, 1), stop_offset=Offset(0, 1))
>>> timespan.round_offsets(
...     2,
...     anchor=abjad.Right,
...     must_be_well_formed=False,
...     )
Timespan(start_offset=Offset(0, 1), stop_offset=Offset(0, 1))

Returns new timespan.

scale(multiplier, anchor=Left)

Scales timespan by multiplier.

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

Scale timespan relative to timespan start offset:

>>> timespan.scale(abjad.Multiplier(2))
Timespan(start_offset=Offset(3, 1), stop_offset=Offset(9, 1))

Scale timespan relative to timespan stop offset:

>>> timespan.scale(abjad.Multiplier(2), anchor=abjad.Right)
Timespan(start_offset=Offset(0, 1), stop_offset=Offset(6, 1))

Returns new timespan.

set_duration(duration)

Sets timespan duration to duration.

>>> timespan = abjad.Timespan((1, 2), (3, 2))
>>> timespan.set_duration((3, 5))
Timespan(start_offset=Offset(1, 2), stop_offset=Offset(11, 10))

Returns new timespan.

set_offsets(start_offset=None, stop_offset=None)

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(start_offset=Offset(1, 2), stop_offset=Offset(7, 8))

Subtracts negative start_offset from existing stop offset:

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

Subtracts negative stop_offset from existing stop offset:

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

Returns new timespan.

split_at_offset(offset)

Split into two parts when offset happens during timespan:

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

Otherwise return a copy of timespan:

>>> timespan.split_at_offset((12, 1))[0]
Timespan(start_offset=Offset(0, 1), stop_offset=Offset(5, 1))

Returns one or two newly constructed timespans.

split_at_offsets(offsets)

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

>>> timespan = abjad.Timespan(0, 10)
>>> result = timespan.split_at_offsets((1, 3, 7))
>>> abjad.f(result)
abjad.TimespanList(
    [
        abjad.Timespan(
            start_offset=abjad.Offset(0, 1),
            stop_offset=abjad.Offset(1, 1),
            ),
        abjad.Timespan(
            start_offset=abjad.Offset(1, 1),
            stop_offset=abjad.Offset(3, 1),
            ),
        abjad.Timespan(
            start_offset=abjad.Offset(3, 1),
            stop_offset=abjad.Offset(7, 1),
            ),
        abjad.Timespan(
            start_offset=abjad.Offset(7, 1),
            stop_offset=abjad.Offset(10, 1),
            ),
        ]
    )

Otherwise return a timespan list containing a copy of timespan:

>>> result = timespan.split_at_offsets((-100,))
>>> abjad.f(result)
abjad.TimespanList(
    [
        abjad.Timespan(
            start_offset=abjad.Offset(0, 1),
            stop_offset=abjad.Offset(10, 1),
            ),
        ]
    )

Returns one or more newly constructed timespans.

starts_after_offset(offset)

Is true when timespan overlaps start of timespan.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_1.starts_after_offset((-5, 1))
True
>>> timespan_1.starts_after_offset((0, 1))
False
>>> timespan_1.starts_after_offset((5, 1))
False

Returns true or false.

starts_after_timespan_starts(timespan)

Is true when timespan starts after timespan starts.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 15)
>>> timespan_1.starts_after_timespan_starts(timespan_1)
False
>>> timespan_1.starts_after_timespan_starts(timespan_2)
False
>>> timespan_2.starts_after_timespan_starts(timespan_1)
True
>>> timespan_2.starts_after_timespan_starts(timespan_2)
False

Returns true or false.

starts_after_timespan_stops(timespan)

Is true when timespan starts after timespan stops.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 15)
>>> timespan_3 = abjad.Timespan(10, 20)
>>> timespan_4 = abjad.Timespan(15, 25)
>>> timespan_1.starts_after_timespan_stops(timespan_1)
False
>>> timespan_2.starts_after_timespan_stops(timespan_1)
False
>>> timespan_3.starts_after_timespan_stops(timespan_1)
True
>>> timespan_4.starts_after_timespan_stops(timespan_1)
True

Returns true or false.

starts_at_offset(offset)

Is true when timespan starts at offset.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_1.starts_at_offset((-5, 1))
False
>>> timespan_1.starts_at_offset((0, 1))
True
>>> timespan_1.starts_at_offset((5, 1))
False

Returns true or false.

starts_at_or_after_offset(offset)

Is true when timespan starts at or after offset.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_1.starts_at_or_after_offset((-5, 1))
True
>>> timespan_1.starts_at_or_after_offset((0, 1))
True
>>> timespan_1.starts_at_or_after_offset((5, 1))
False

Returns true or false.

starts_before_offset(offset)

Is true when timespan starts before offset.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_1.starts_before_offset((-5, 1))
False
>>> timespan_1.starts_before_offset((0, 1))
False
>>> timespan_1.starts_before_offset((5, 1))
True

Returns true or false.

starts_before_or_at_offset(offset)

Is true when timespan starts before or at offset.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_1.starts_before_or_at_offset((-5, 1))
False
>>> timespan_1.starts_before_or_at_offset((0, 1))
True
>>> timespan_1.starts_before_or_at_offset((5, 1))
True

Returns true or false.

starts_before_timespan_starts(timespan)

Is true when timespan starts before timespan starts.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 15)
>>> timespan_1.starts_before_timespan_starts(timespan_1)
False
>>> timespan_1.starts_before_timespan_starts(timespan_2)
True
>>> timespan_2.starts_before_timespan_starts(timespan_1)
False
>>> timespan_2.starts_before_timespan_starts(timespan_2)
False

Returns true or false.

starts_before_timespan_stops(timespan)

Is true when timespan starts before timespan stops.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 15)
>>> timespan_1.starts_before_timespan_stops(timespan_1)
True
>>> timespan_1.starts_before_timespan_stops(timespan_2)
True
>>> timespan_2.starts_before_timespan_stops(timespan_1)
True
>>> timespan_2.starts_before_timespan_stops(timespan_2)
True

Returns true or false.

starts_during_timespan(timespan)

Is true when timespan starts during timespan.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 15)
>>> timespan_1.starts_during_timespan(timespan_1)
True
>>> timespan_1.starts_during_timespan(timespan_2)
False
>>> timespan_2.starts_during_timespan(timespan_1)
True
>>> timespan_2.starts_during_timespan(timespan_2)
True

Returns true or false.

starts_when_timespan_starts(timespan)

Is true when timespan starts when timespan starts.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 15)
>>> timespan_1.starts_when_timespan_starts(timespan_1)
True
>>> timespan_1.starts_when_timespan_starts(timespan_2)
False
>>> timespan_2.starts_when_timespan_starts(timespan_1)
False
>>> timespan_2.starts_when_timespan_starts(timespan_2)
True

Returns true or false.

starts_when_timespan_stops(timespan)

Is true when timespan starts when timespan stops.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(10, 20)
>>> timespan_1.starts_when_timespan_stops(timespan_1)
False
>>> timespan_1.starts_when_timespan_stops(timespan_2)
False
>>> timespan_2.starts_when_timespan_stops(timespan_1)
True
>>> timespan_2.starts_when_timespan_stops(timespan_2)
False

Returns true or false.

stops_after_offset(offset)

Is true when timespan stops after offset.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_1.starts_after_offset((-5, 1))
True
>>> timespan_1.starts_after_offset((0, 1))
False
>>> timespan_1.starts_after_offset((5, 1))
False

Returns true or false.

stops_after_timespan_starts(timespan)

Is true when timespan stops when timespan starts.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(10, 20)
>>> timespan_1.stops_after_timespan_starts(timespan_1)
True
>>> timespan_1.stops_after_timespan_starts(timespan_2)
False
>>> timespan_2.stops_after_timespan_starts(timespan_1)
True
>>> timespan_2.stops_after_timespan_starts(timespan_2)
True

Returns true or false.

stops_after_timespan_stops(timespan)

Is true when timespan stops when timespan stops.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(10, 20)
>>> timespan_1.stops_after_timespan_stops(timespan_1)
False
>>> timespan_1.stops_after_timespan_stops(timespan_2)
False
>>> timespan_2.stops_after_timespan_stops(timespan_1)
True
>>> timespan_2.stops_after_timespan_stops(timespan_2)
False

Returns true or false.

stops_at_offset(offset)

Is true when timespan stops at offset.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_1.stops_at_offset((-5, 1))
False
>>> timespan_1.stops_at_offset((0, 1))
False
>>> timespan_1.stops_at_offset((5, 1))
False

Returns true or false.

stops_at_or_after_offset(offset)

Is true when timespan stops at or after offset.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_1.stops_at_or_after_offset((-5, 1))
True
>>> timespan_1.stops_at_or_after_offset((0, 1))
True
>>> timespan_1.stops_at_or_after_offset((5, 1))
True

Returns true or false.

stops_before_offset(offset)

Is true when timespan stops before offset.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_1.stops_before_offset((-5, 1))
False
>>> timespan_1.stops_before_offset((0, 1))
False
>>> timespan_1.stops_before_offset((5, 1))
False

Returns true or false.

stops_before_or_at_offset(offset)

Is true when timespan stops before or at offset.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_1.stops_before_or_at_offset((-5, 1))
False
>>> timespan_1.stops_before_or_at_offset((0, 1))
False
>>> timespan_1.stops_before_or_at_offset((5, 1))
False

Returns true or false.

stops_before_timespan_starts(timespan)

Is true when timespan stops before timespan starts.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(10, 20)
>>> timespan_1.stops_before_timespan_starts(timespan_1)
False
>>> timespan_1.stops_before_timespan_starts(timespan_2)
False
>>> timespan_2.stops_before_timespan_starts(timespan_1)
False
>>> timespan_2.stops_before_timespan_starts(timespan_2)
False

Returns true or false.

stops_before_timespan_stops(timespan)

Is true when timespan stops before timespan stops.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(10, 20)
>>> timespan_1.stops_before_timespan_stops(timespan_1)
False
>>> timespan_1.stops_before_timespan_stops(timespan_2)
True
>>> timespan_2.stops_before_timespan_stops(timespan_1)
False
>>> timespan_2.stops_before_timespan_stops(timespan_2)
False

Returns true or false.

stops_during_timespan(timespan)

Is true when timespan stops during timespan.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(10, 20)
>>> timespan_1.stops_during_timespan(timespan_1)
True
>>> timespan_1.stops_during_timespan(timespan_2)
False
>>> timespan_2.stops_during_timespan(timespan_1)
False
>>> timespan_2.stops_during_timespan(timespan_2)
True

Returns true or false.

stops_when_timespan_starts(timespan)

Is true when timespan stops when timespan starts.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(10, 20)
>>> timespan_1.stops_when_timespan_starts(timespan_1)
False
>>> timespan_1.stops_when_timespan_starts(timespan_2)
True
>>> timespan_2.stops_when_timespan_starts(timespan_1)
False
>>> timespan_2.stops_when_timespan_starts(timespan_2)
False

Returns true or false.

stops_when_timespan_stops(timespan)

Is true when timespan stops when timespan stops.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(10, 20)
>>> timespan_1.stops_when_timespan_stops(timespan_1)
True
>>> timespan_1.stops_when_timespan_stops(timespan_2)
False
>>> timespan_2.stops_when_timespan_stops(timespan_1)
False
>>> timespan_2.stops_when_timespan_stops(timespan_2)
True

Returns true or false.

stretch(multiplier, anchor=None)

Stretches timespan by multiplier relative to anchor.

Stretch relative to timespan start offset:

>>> abjad.Timespan(3, 10).stretch(abjad.Multiplier(2))
Timespan(start_offset=Offset(3, 1), stop_offset=Offset(17, 1))

Stretch relative to timespan stop offset:

>>> abjad.Timespan(3, 10).stretch(
...     abjad.Multiplier(2),
...     abjad.Offset(10),
...     )
Timespan(start_offset=Offset(-4, 1), stop_offset=Offset(10, 1))

Stretch relative to offset prior to timespan:

>>> abjad.Timespan(3, 10).stretch(
...     abjad.Multiplier(2),
...     abjad.Offset(0, 1),
...     )
Timespan(start_offset=Offset(6, 1), stop_offset=Offset(20, 1))

Stretch relative to offset after timespan:

>>> abjad.Timespan(3, 10).stretch(
...     abjad.Multiplier(3),
...     abjad.Offset(12),
...     )
Timespan(start_offset=Offset(-15, 1), stop_offset=Offset(6, 1))

Stretch relative to offset that happens during timespan:

>>> abjad.Timespan(3, 10).stretch(
...     abjad.Multiplier(2),
...     abjad.Offset(4),
...     )
Timespan(start_offset=Offset(2, 1), stop_offset=Offset(16, 1))

Returns newly emitted timespan.

translate(translation=None)

Translates timespan by translation.

>>> timespan = abjad.Timespan(5, 10)
>>> timespan.translate(2)
Timespan(start_offset=Offset(7, 1), stop_offset=Offset(12, 1))

Returns new timespan.

translate_offsets(start_offset_translation=None, stop_offset_translation=None)

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(start_offset=Offset(3, 8), stop_offset=Offset(3, 2))

Returns new timespan.

trisects_timespan(timespan)

Is true when timespan trisects timespan.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 6)
>>> timespan_1.trisects_timespan(timespan_1)
False
>>> timespan_1.trisects_timespan(timespan_2)
False
>>> timespan_2.trisects_timespan(timespan_1)
True
>>> timespan_2.trisects_timespan(timespan_2)
False

Returns true or false.


Read-only properties

axis

Arithmetic mean of timespan start- and stop-offsets.

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

Returns offset.

duration

Duration of timespan.

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

Returns duration.

is_well_formed

Is true when timespan start offset preceeds timespan stop offset.

>>> abjad.Timespan(0, 10).is_well_formed
True

Returns true or false.

offsets

Timespan offsets.

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

Returns offset pair.

start_offset

Timespan start offset.

>>> abjad.Timespan(0, 10).start_offset
Offset(0, 1)

Returns offset.

stop_offset

Timespan stop offset.

>>> abjad.Timespan(0, 10).stop_offset
Offset(10, 1)

Returns offset.