TimespanTimespanTimeRelation

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.TimeRelation.TimeRelation" [URL="../api/abjad/timespans/TimeRelation.html#abjad.timespans.TimeRelation.TimeRelation", label="Time\nRelation", shape=oval, style=bold, target=_top]; "abjad.timespans.TimespanTimespanTimeRelation.TimespanTimespanTimeRelation" [URL="../api/abjad/timespans/TimespanTimespanTimeRelation.html#abjad.timespans.TimespanTimespanTimeRelation.TimespanTimespanTimeRelation", color=black, fontcolor=white, label="Timespan\nTimespan\nTime\nRelation", target=_top]; "abjad.timespans.TimeRelation.TimeRelation" -> "abjad.timespans.TimespanTimespanTimeRelation.TimespanTimespanTimeRelation"; } 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.TimeRelation.TimeRelation"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjad.timespans.TimespanTimespanTimeRelation.TimespanTimespanTimeRelation(inequality=None, timespan_1=None, timespan_2=None)

Timespan vs. timespan time relation.

Score for examples:

>>> string = r"\times 2/3 { c'4 d'4 e'4 } \times 2/3 { f'4 g'4 a'4 }"
>>> staff_1 = abjad.Staff(string)
>>> staff_2 = abjad.Staff("c'2. d'4")
>>> score = abjad.Score([staff_1, staff_2])
>>> last_tuplet = staff_1[-1]
>>> long_note = staff_2[0]
>>> abjad.show(score) 
>>> abjad.timespans.timespan_2_happens_during_timespan_1(
...     timespan_1=last_tuplet,
...     timespan_2=long_note,
...     )
False
>>> abjad.timespans.timespan_2_intersects_timespan_1(
...     timespan_1=last_tuplet,
...     timespan_2=long_note,
...     )
True
>>> abjad.timespans.timespan_2_is_congruent_to_timespan_1(
...     timespan_1=last_tuplet,
...     timespan_2=long_note,
...     )
False
>>> abjad.timespans.timespan_2_overlaps_all_of_timespan_1(
...     timespan_1=last_tuplet,
...     timespan_2=long_note,
...     )
False
>>> abjad.timespans.timespan_2_overlaps_start_of_timespan_1(
...     timespan_1=last_tuplet,
...     timespan_2=long_note,
...     )
True
>>> abjad.timespans.timespan_2_overlaps_stop_of_timespan_1(
...     timespan_1=last_tuplet,
...     timespan_2=long_note,
...     )
False
>>> abjad.timespans.timespan_2_starts_after_timespan_1_starts(
...     timespan_1=last_tuplet,
...     timespan_2=long_note,
...     )
False
>>> abjad.timespans.timespan_2_starts_after_timespan_1_stops(
...     timespan_1=last_tuplet,
...     timespan_2=long_note,
...     )
False

Timespan / timespan time relations are immutable.


Attributes Summary

__call__ Evaluate time relation.
__eq__ Is true when argument equals time relation.
__hash__ Hashes time relation.
get_counttime_components Get counttime_components that satisfy time_relation:
get_offset_indices Get offset indices that satisfy time relation:
is_fully_loaded Is true when timespan_1 and timespan_2 are both not none.
is_fully_unloaded Is true when timespan_1 and timespan_2 are both none.
timespan_1 Time relation timespan 1:
timespan_2 Time relation timespan 2:

Special methods

__call__(timespan_1=None, timespan_2=None)

Evaluate time relation.

Evaluate time relation without substitution:

>>> timespan_1 = abjad.Timespan(5, 15)
>>> timespan_2 = abjad.Timespan(10, 20)
>>> time_relation = abjad.timespans.timespan_2_starts_during_timespan_1(
...     timespan_1=timespan_1,
...     timespan_2=timespan_2,
...     hold=True,
...     )
>>> abjad.f(time_relation)
abjad.timespans.TimespanTimespanTimeRelation(
    inequality=abjad.timespans.CompoundInequality(
        [
            abjad.TimespanInequality('timespan_1.start_offset <= timespan_2.start_offset'),
            abjad.TimespanInequality('timespan_2.start_offset < timespan_1.stop_offset'),
            ],
        logical_operator='and',
        ),
    timespan_1=abjad.Timespan(
        start_offset=abjad.Offset(5, 1),
        stop_offset=abjad.Offset(15, 1),
        ),
    timespan_2=abjad.Timespan(
        start_offset=abjad.Offset(10, 1),
        stop_offset=abjad.Offset(20, 1),
        ),
    )
>>> time_relation()
True

Substitute timespan_1 during evaluation:

>>> new_timespan_1 = abjad.Timespan(0, 10)
>>> new_timespan_1
Timespan(start_offset=Offset(0, 1), stop_offset=Offset(10, 1))
>>> time_relation(timespan_1=new_timespan_1)
False

Substitute timespan_2 during evaluation:

>>> new_timespan_2 = abjad.Timespan(2, 12)
>>> new_timespan_2
Timespan(start_offset=Offset(2, 1), stop_offset=Offset(12, 1))
>>> time_relation(timespan_2=new_timespan_2)
False

Substitute both timespan_1 and timespan_2 during evaluation:

>>> time_relation(
...     timespan_1=new_timespan_1,
...     timespan_2=new_timespan_2,
...     )
True

Raise value error if either timespan_1 or timespan_2 is none.

Otherwise return boolean.

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

__eq__(argument)

Is true when argument equals time relation.

>>> timespan = abjad.Timespan(0, 10)
>>> time_relation_1 = abjad.timespans.timespan_2_starts_during_timespan_1()
>>> time_relation_2 = abjad.timespans.timespan_2_starts_during_timespan_1(
...     timespan_1=timespan)
>>> time_relation_1 == time_relation_1
True
>>> time_relation_1 == time_relation_2
False
>>> time_relation_2 == time_relation_2
True

Returns true or false.

(TimeRelation).__format__(format_specification='')

Formats time relation.

Returns string.

__hash__()

Hashes time relation.

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

Returns integer.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.


Methods

get_counttime_components(counttime_components)

Get counttime_components that satisfy time_relation:

>>> notes = [abjad.Note(_ % 36, (1, 4)) for _ in range(200)]
>>> voice = abjad.Voice(notes)
>>> timespan_1 = abjad.Timespan(20, 22)
>>> time_relation = abjad.timespans.timespan_2_starts_during_timespan_1(
...     timespan_1=timespan_1)
>>> result = time_relation.get_counttime_components(voice[:])
>>> for counttime_component in result:
...     counttime_component
... 
Note("af'4")
Note("a'4")
Note("bf'4")
Note("b'4")
Note("c''4")
Note("cs''4")
Note("d''4")
Note("ef''4")
>>> abjad.inspect(result).timespan()
Timespan(start_offset=Offset(20, 1), stop_offset=Offset(22, 1))

counttime_components must belong to a single voice.

counttime_components must be time-contiguous.

The call shown here takes 78355 function calls under r9686.

Returns selection.

get_offset_indices(timespan_2_start_offsets, timespan_2_stop_offsets)

Get offset indices that satisfy time relation:

>>> staff = abjad.Staff("c'8 d'8 e'8 f'8 g'8 a'8 b'8 c''8")
>>> start_offsets = [
...     abjad.inspect(note).timespan().start_offset
...     for note in staff
...     ]
>>> stop_offsets = [
...     abjad.inspect(note).timespan().stop_offset
...     for note in staff
...     ]

Notes equal to staff[0:2] start during timespan [0, 3/16):

>>> timespan_1 = abjad.Timespan((0), (3, 16))
>>> time_relation = abjad.timespans.timespan_2_starts_during_timespan_1(
...     timespan_1=timespan_1,
...     )
>>> time_relation.get_offset_indices(start_offsets, stop_offsets)
(0, 2)

Notes equal to staff[2:8] start after timespan [0, 3/16) stops:

>>> timespan_1 = abjad.Timespan((0), (3, 16))
>>> time_relation =  abjad.timespans.timespan_2_starts_after_timespan_1_stops(
...     timespan_1=timespan_1,
...     )
>>> time_relation.get_offset_indices(start_offsets, stop_offsets)
(2, 8)

Returns nonnegative integer pair.


Read-only properties

(TimeRelation).inequality

Time relation inequality.

Return ineqality.

is_fully_loaded

Is true when timespan_1 and timespan_2 are both not none.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 15)
>>> time_relation = abjad.timespans.timespan_2_starts_during_timespan_1(
...     timespan_1=timespan_1,
...     timespan_2=timespan_2,
...     hold=True,
...     )
>>> time_relation.is_fully_loaded
True

Returns true or false.

is_fully_unloaded

Is true when timespan_1 and timespan_2 are both none.

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 15)
>>> time_relation = abjad.timespans.timespan_2_starts_during_timespan_1(
...     timespan_1=timespan_1,
...     timespan_2=timespan_2,
...     hold=True,
...     )
>>> time_relation.is_fully_unloaded
False

Returns true or false.

timespan_1

Time relation timespan 1:

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 15)
>>> time_relation = abjad.timespans.timespan_2_starts_during_timespan_1(
...     timespan_1=timespan_1,
...     timespan_2=timespan_2,
...     hold=True,
...     )
>>> time_relation.timespan_1
Timespan(start_offset=Offset(0, 1), stop_offset=Offset(10, 1))

Returns timespan.

timespan_2

Time relation timespan 2:

>>> timespan_1 = abjad.Timespan(0, 10)
>>> timespan_2 = abjad.Timespan(5, 15)
>>> time_relation = abjad.timespans.timespan_2_starts_during_timespan_1(
...     timespan_1=timespan_1,
...     timespan_2=timespan_2,
...     hold=True,
...     )
>>> time_relation.timespan_2
Timespan(start_offset=Offset(5, 1), stop_offset=Offset(15, 1))

Returns timespan.