TimespanList

class timespantools.TimespanList(items=None, item_class=None, keep_sorted=False)

Timespan list.

Contiguous timespan list:

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

Overlapping timespan list:

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

Empty timespan list:

>>> timespantools.TimespanList()
TimespanList([])

Operations on timespan currently work in place.

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_abctools { graph [label=abctools]; "abjad.tools.abctools.AbjadObject.AbjadObject" [color=1, group=0, label=AbjadObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" [color=1, group=0, label=AbstractBase, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_datastructuretools { graph [label=datastructuretools]; "abjad.tools.datastructuretools.TypedCollection.TypedCollection" [color=3, group=2, label=TypedCollection, shape=oval, style=bold]; "abjad.tools.datastructuretools.TypedList.TypedList" [color=3, group=2, label=TypedList, shape=box]; "abjad.tools.datastructuretools.TypedCollection.TypedCollection" -> "abjad.tools.datastructuretools.TypedList.TypedList"; } subgraph cluster_timespantools { graph [label=timespantools]; "abjad.tools.timespantools.TimespanList.TimespanList" [color=black, fontcolor=white, group=3, label=<<B>TimespanList</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.datastructuretools.TypedCollection.TypedCollection"; "abjad.tools.datastructuretools.TypedList.TypedList" -> "abjad.tools.timespantools.TimespanList.TimespanList"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Attribute summary

all_are_contiguous Is true when all timespans are contiguous.
all_are_nonoverlapping Is true when all timespans are nonoverlapping.
all_are_well_formed Is true when all timespans are well-formed.
append(item) Appends item to typed list.
axis Gets axis defined equal to arithmetic mean of start- and stop-offsets.
clip_timespan_durations([minimum, maximum, ...]) 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([timespan]) Computes overlap factor of timespans.
compute_overlap_factor_mapping() Computes overlap factor for each consecutive offset pair in timespans.
count(item) Gets count of item in typed list.
count_offsets() Counts offsets.
duration Gets duration of timespan list.
explode([inventory_count]) Explodes timespans into timespan lists, avoiding overlap, and distributing density as evenly as possible.
extend(items) Extends typed list with items.
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 timespan list has timespan that satisfies time_relation.
index(item) Gets index of item in typed list.
insert(i, item) Insert item into typed list.
is_sorted Is true when timespans are in time order.
item_class Gets item class of collection.
items Gets items in collection.
keep_sorted Is true when typed list keeps items sorted.
partition([include_tangent_timespans]) Partitions timespans into timespan_lists.
pop([i]) Pops item i from typed list.
reflect([axis]) Reflects timespans.
remove(item) Removes item from typed list.
remove_degenerate_timespans() Removes degenerate timespans.
repeat_to_stop_offset(stop_offset) Repeats timespans to stop_offset.
reverse() Reverses items in typed list.
rotate(count) Rotates by count contiguous timespans.
round_offsets(multiplier[, anchor, ...]) Rounds offsets of timespans in list to multiples of multiplier.
scale(multiplier[, anchor]) Scales timespan by multiplier relative to anchor.
sort([cmp, key, reverse]) Sorts items in typed list.
split_at_offset(offset) Splits timespans at offset.
split_at_offsets(offsets) Splits timespans at offsets.
start_offset Gets start offset.
stop_offset Gets stop offset.
stretch(multiplier[, anchor]) Stretches timespans by multiplier relative to anchor.
timespan Gets timespan of timespan list.
translate([translation]) Translates timespans by translation.
translate_offsets([...]) Translates timespans by start_offset_translation and stop_offset_translation.
__and__(timespan) Keeps material that intersects timespan.
__contains__(item) Is true when typed collection contains item.
__delitem__(i) Aliases list.__delitem__().
__eq__(argument) Is true when argument is a typed collection with items that compare equal to those of this typed collection.
__format__([format_specification]) Formats Abjad object.
__getitem__(argument) Gets item or slice identified by argument.
__hash__() Hashes typed collection.
__iadd__(argument) Adds argument in place to typed list.
__illustrate__([key, range_, sortkey, scale]) Illustrates timespans.
__invert__() Inverts timespans.
__iter__() Iterates typed collection.
__len__() Gets length of typed collection.
__ne__(argument) Is true when argument is not a typed collection with items equal to this typed collection.
__repr__() Gets interpreter representation of Abjad object.
__reversed__() Aliases list.__reversed__().
__setitem__(i, argument) Sets item i equal to argument.
__sub__(timespan) Deletes material that intersects timespan.

Read-only properties

TimespanList.all_are_contiguous

Is true when all timespans are contiguous.

Is true when all timespans are contiguous:

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

Is false when timespans not contiguous:

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

Is true when timespan list is empty:

>>> timespantools.TimespanList().all_are_contiguous
True

Returns true or false.

TimespanList.all_are_nonoverlapping

Is true when all timespans are nonoverlapping.

Is true when all timespans are nonoverlapping:

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

Is false when timespans are overlapping:

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

Is true when timespan list is empty:

>>> timespantools.TimespanList().all_are_nonoverlapping
True

Returns true or false.

TimespanList.all_are_well_formed

Is true when all timespans are well-formed.

Is true when all timespans are well-formed:

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

Is true when all timespans are well-formed:

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

Is true when timespan list is empty:

>>> timespantools.TimespanList().all_are_well_formed
True

Is false when timespans are not all well-formed.

Returns true or false.

TimespanList.axis

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

Gets axis:

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

Gets axis:

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

Gets none when timespan list is empty:

>>> timespantools.TimespanList().axis is None
True

Returns offset or none.

TimespanList.duration

Gets duration of timespan list.

Gets duration:

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

Gets duration:

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

Gets zero when timespan list is empty:

>>> timespantools.TimespanList().duration
Duration(0, 1)

Returns duration.

TimespanList.is_sorted

Is true when timespans are in time order.

Is true when timespans are sorted:

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

Is false when timespans are not sorted:

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

Returns true or false.

(TypedCollection).item_class

Gets item class of collection.

Collection coerces items according to item_class.

Returns class.

(TypedCollection).items

Gets items in collection.

Returns list.

TimespanList.start_offset

Gets start offset.

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

Gets start offset:

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

Gets start offset:

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

Gets negative infinity when timespan list is empty:

>>> timespantools.TimespanList().start_offset
NegativeInfinity

Returns offset or none.

TimespanList.stop_offset

Gets stop offset.

Defined equal to latest stop offset of any timespan.

Gets stop offset:

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

Gets stop offset:

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

Gets infinity when timespan list is empty:

>>> timespantools.TimespanList().stop_offset
Infinity

Returns offset or none.

TimespanList.timespan

Gets timespan of timespan list.

Gets timespan:

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

Gets timespan:

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

Gets infinite timespan when list is empty:

>>> timespantools.TimespanList().timespan
Timespan(start_offset=NegativeInfinity, stop_offset=Infinity)

Returns timespan.

Read/write properties

(TypedList).keep_sorted

Is true when typed list keeps items sorted. Otherwise false.

Defaults to none.

Set to true, false or none.

Returns true, false or none.

Methods

(TypedList).append(item)

Appends item to typed list.

>>> integer_list = datastructuretools.TypedList(item_class=int)
>>> integer_list.append('1')
>>> integer_list.append(2)
>>> integer_list.append(3.4)
>>> integer_list[:]
[1, 2, 3]

Returns none.

TimespanList.clip_timespan_durations(minimum=None, maximum=None, anchor=Left)

Clips timespan durations.

Clips timespan durations:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 1),
...     timespantools.Timespan(0, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> result = timespans.clip_timespan_durations(
...     minimum=5,
...     )
>>> show(result, range_=(0, 10), scale=0.5) 
>>> f(result)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(5, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Clips timespan durations:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 1),
...     timespantools.Timespan(0, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> result = timespans.clip_timespan_durations(
...     maximum=5,
...     )
>>> show(result, range_=(0, 10), scale=0.5) 
>>> f(result)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(1, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(5, 1),
            ),
        ]
    )

Clips timespan durations:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 1),
...     timespantools.Timespan(0, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> result = timespans.clip_timespan_durations(
...     minimum=3,
...     maximum=7,
...     )
>>> show(result, range_=(0, 10), scale=0.5) 
>>> f(result)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(3, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(7, 1),
            ),
        ]
    )

Clips timespan durations:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 1),
...     timespantools.Timespan(0, 10),
...     ])
>>> show(timespans, range_=(-2, 10), scale=0.5) 
>>> result = timespans.clip_timespan_durations(
...     minimum=3,
...     maximum=7,
...     anchor=Right,
...     )
>>> show(result, range_=(-2, 10), scale=0.5) 
>>> f(result)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(-2, 1),
            stop_offset=durationtools.Offset(1, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(3, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Returns new timespan list.

TimespanList.compute_logical_and()

Computes logical AND of timespans.

Computes logical AND:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> _ = timespans.compute_logical_and()
>>> show(timespans, range_=(0, 10), scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Computes logical AND:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 10),
...     timespantools.Timespan(5, 12),
...     ])
>>> show(timespans, scale=0.5) 
>>> _ = timespans.compute_logical_and()
>>> show(timespans, range_=(0, 12), scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(5, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Computes logical AND:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 10),
...     timespantools.Timespan(5, 12),
...     timespantools.Timespan(-2, 8),
...     ])
>>> show(timespans, range_=(-2, 12), scale=0.5) 
>>> _ = timespans.compute_logical_and()
>>> show(timespans, range_=(-2, 12), scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(5, 1),
            stop_offset=durationtools.Offset(8, 1),
            ),
        ]
    )

Same as setwise intersection.

Operates in place and returns timespan list.

TimespanList.compute_logical_or()

Computes logical OR of timespans.

Computes logical OR:

>>> timespans = timespantools.TimespanList()
>>> _ = timespans.compute_logical_or()
>>> timespans
TimespanList([])

Computes logical OR:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> _ = timespans.compute_logical_or()
>>> show(timespans, range_=(0, 10), scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Computes logical OR:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 10),
...     timespantools.Timespan(5, 12),
...     ])
>>> show(timespans, scale=0.5) 
>>> _ = timespans.compute_logical_or()
>>> show(timespans, range_=(0, 12), scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(12, 1),
            ),
        ]
    )

Computes logical OR:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 10),
...     timespantools.Timespan(5, 12),
...     timespantools.Timespan(-2, 2),
...     ])
>>> show(timespans, range_=(-2, 12), scale=0.5) 
>>> _ = timespans.compute_logical_or()
>>> show(timespans, range_=(-2, 12), scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(-2, 1),
            stop_offset=durationtools.Offset(12, 1),
            ),
        ]
    )

Computes logical OR:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(-2, 2),
...     timespantools.Timespan(10, 20),
...     ])
>>> show(timespans, scale=0.5) 
>>> _ = timespans.compute_logical_or()
>>> show(timespans, range_=(-2, 20), scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(-2, 1),
            stop_offset=durationtools.Offset(2, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(10, 1),
            stop_offset=durationtools.Offset(20, 1),
            ),
        ]
    )

Operates in place and returns timespan list.

TimespanList.compute_logical_xor()

Computes logical XOR of timespans.

Computes logical XOR:

>>> timespans = timespantools.TimespanList()
>>> _ = timespans.compute_logical_xor()
>>> timespans
TimespanList([])

Computes logical XOR:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> _ = timespans.compute_logical_xor()
>>> show(timespans, range_=(0, 10), scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Computes logical XOR:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 10),
...     timespantools.Timespan(5, 12),
...     ])
>>> show(timespans, range_=(0, 12), scale=0.5) 
>>> _ = timespans.compute_logical_xor()
>>> show(timespans, range_=(0, 12), scale=0.5) 

Computes logical XOR:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 10),
...     timespantools.Timespan(5, 12),
...     timespantools.Timespan(-2, 2),
...     ])
>>> show(timespans, range_=(0, 12), scale=0.5) 
>>> _ = timespans.compute_logical_xor()
>>> show(timespans, scale=0.5) 

Computes logical XOR:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(-2, 2),
...     timespantools.Timespan(10, 20),
...     ])
>>> show(timespans, scale=0.5) 
>>> _ = timespans.compute_logical_xor()
>>> show(timespans, range_=(-2, 20), scale=0.5) 

Computes logical XOR:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 10),
...     timespantools.Timespan(4, 8),
...     timespantools.Timespan(2, 6),
...     ])
>>> show(timespans, scale=0.5) 
>>> _ = timespans.compute_logical_xor()
>>> show(timespans, range_=(0, 10), scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(2, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(8, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Computes logical XOR:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 10),
...     timespantools.Timespan(0, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> _ = timespans.compute_logical_xor()
>>> timespans
TimespanList([])

Operates in place and returns timespan list.

TimespanList.compute_overlap_factor(timespan=None)

Computes overlap factor of timespans.

Example timespan list:

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

Computes overlap factor across the entire list:

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

Computes overlap factor within a specific timespan:

>>> timespans.compute_overlap_factor(
...     timespan=timespantools.Timespan(-15, 0))
Multiplier(0, 1)

Computes overlap factor:

>>> timespans.compute_overlap_factor(
...     timespan=timespantools.Timespan(-10, 5))
Multiplier(1, 3)

Computes overlap factor:

>>> timespans.compute_overlap_factor(
...     timespan=timespantools.Timespan(-5, 10))
Multiplier(1, 1)

Computes overlap factor:

>>> timespans.compute_overlap_factor(
...     timespan=timespantools.Timespan(0, 15))
Multiplier(4, 3)

Computes overlap factor:

>>> timespans.compute_overlap_factor(
...     timespan=timespantools.Timespan(5, 20))
Multiplier(1, 1)

Computes overlap factor:

>>> timespans.compute_overlap_factor(
...     timespan=timespantools.Timespan(10, 25))
Multiplier(1, 1)

Computes overlap factor:

>>> timespans.compute_overlap_factor(
...     timespan=timespantools.Timespan(15, 30))
Multiplier(1, 1)

Returns multiplier.

TimespanList.compute_overlap_factor_mapping()

Computes overlap factor for each consecutive offset pair in timespans.

Computes overlap factor mapping:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 10),
...     timespantools.Timespan(5, 15),
...     timespantools.Timespan(20, 25),
...     timespantools.Timespan(20, 30),
...     ])
>>> 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), Multiplier(1, 1))
(Offset(5, 1), Offset(10, 1), Multiplier(2, 1))
(Offset(10, 1), Offset(15, 1), Multiplier(1, 1))
(Offset(15, 1), Offset(20, 1), Multiplier(0, 1))
(Offset(20, 1), Offset(25, 1), Multiplier(2, 1))
(Offset(25, 1), Offset(30, 1), Multiplier(1, 1))

Returns mapping.

(TypedList).count(item)

Gets count of item in typed list.

>>> integer_list = datastructuretools.TypedList(item_class=int)
>>> integer_list.extend([0, 0., '0', 99])
>>> integer_list.count(0)
3
>>> integer_list.count(1)
0
>>> integer_list.count(99)
1

Returns nonnegative integer.

TimespanList.count_offsets()

Counts offsets.

Counts offsets:

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

Counts offsets:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 16),
...     timespantools.Timespan(5, 12),
...     timespantools.Timespan(-2, 8),
...     timespantools.Timespan(15, 20),
...     timespantools.Timespan(24, 30),
...     ])
>>> show(timespans, scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(16, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(5, 1),
            stop_offset=durationtools.Offset(12, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(-2, 1),
            stop_offset=durationtools.Offset(8, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(15, 1),
            stop_offset=durationtools.Offset(20, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(24, 1),
            stop_offset=durationtools.Offset(30, 1),
            ),
        ]
    )
>>> offset_counter = timespans.count_offsets()
>>> show(offset_counter, range_=(0, 30), scale=0.5) 
>>> for offset, count in sorted(
...     timespans.count_offsets().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 = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(0, 6),
...     timespantools.Timespan(0, 9),
...     ])
>>> show(timespans, scale=0.5) 
>>> offset_counter = timespans.count_offsets()
>>> show(offset_counter, range_=(0, 9), scale=0.5) 
>>> for offset, count in sorted(
...     timespans.count_offsets().items()):
...     offset, count
...
(Offset(0, 1), 3)
(Offset(3, 1), 1)
(Offset(6, 1), 1)
(Offset(9, 1), 1)

Returns counter.

TimespanList.explode(inventory_count=None)

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

Example timespan list:

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

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

>>> for exploded_timespan_list in timespans.explode():
...     f(exploded_timespan_list)
...
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(3, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(5, 1),
            stop_offset=durationtools.Offset(13, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(17, 1),
            stop_offset=durationtools.Offset(19, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(19, 1),
            stop_offset=durationtools.Offset(20, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(34, 1),
            stop_offset=durationtools.Offset(37, 1),
            ),
        ]
    )
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(6, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(16, 1),
            stop_offset=durationtools.Offset(21, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(25, 1),
            stop_offset=durationtools.Offset(30, 1),
            ),
        ]
    )
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(8, 1),
            stop_offset=durationtools.Offset(9, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(15, 1),
            stop_offset=durationtools.Offset(23, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(26, 1),
            stop_offset=durationtools.Offset(29, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(32, 1),
            stop_offset=durationtools.Offset(34, 1),
            ),
        ]
    )

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

>>> for exploded_timespan_list in timespans.explode(
...     inventory_count=2):
...     f(exploded_timespan_list)
...
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(5, 1),
            stop_offset=durationtools.Offset(13, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(15, 1),
            stop_offset=durationtools.Offset(23, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(25, 1),
            stop_offset=durationtools.Offset(30, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(34, 1),
            stop_offset=durationtools.Offset(37, 1),
            ),
        ]
    )
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(3, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(6, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(8, 1),
            stop_offset=durationtools.Offset(9, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(16, 1),
            stop_offset=durationtools.Offset(21, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(17, 1),
            stop_offset=durationtools.Offset(19, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(19, 1),
            stop_offset=durationtools.Offset(20, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(26, 1),
            stop_offset=durationtools.Offset(29, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(32, 1),
            stop_offset=durationtools.Offset(34, 1),
            ),
        ]
    )

Explodes timespans into a greater-than-optimal number of non-overlapping timespan lists:

>>> for exploded_timespan_list in timespans.explode(
...     inventory_count=6):
...     f(exploded_timespan_list)
...
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(16, 1),
            stop_offset=durationtools.Offset(21, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(34, 1),
            stop_offset=durationtools.Offset(37, 1),
            ),
        ]
    )
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(15, 1),
            stop_offset=durationtools.Offset(23, 1),
            ),
        ]
    )
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(8, 1),
            stop_offset=durationtools.Offset(9, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(17, 1),
            stop_offset=durationtools.Offset(19, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(19, 1),
            stop_offset=durationtools.Offset(20, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(26, 1),
            stop_offset=durationtools.Offset(29, 1),
            ),
        ]
    )
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(6, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(32, 1),
            stop_offset=durationtools.Offset(34, 1),
            ),
        ]
    )
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(5, 1),
            stop_offset=durationtools.Offset(13, 1),
            ),
        ]
    )
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(3, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(25, 1),
            stop_offset=durationtools.Offset(30, 1),
            ),
        ]
    )

Returns timespan lists.

(TypedList).extend(items)

Extends typed list with items.

>>> integer_list = datastructuretools.TypedList(item_class=int)
>>> integer_list.extend(['0', 1.0, 2, 3.14159])
>>> integer_list
TypedList([0, 1, 2, 3], item_class=int)

Returns none.

TimespanList.get_timespan_that_satisfies_time_relation(time_relation)

Gets timespan that satisifies time_relation.

Gets timespan:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> timespan = timespantools.Timespan(2, 5)
>>> time_relation = \
...     timespantools.timespan_2_starts_during_timespan_1(
...     timespan_1=timespan)
>>> timespan = timespans.get_timespan_that_satisfies_time_relation(
...     time_relation)
>>> show(timespan, range_=(0, 10), scale=0.5) 
>>> timespan
Timespan(start_offset=Offset(3, 1), stop_offset=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.

TimespanList.get_timespans_that_satisfy_time_relation(time_relation)

Gets timespans that satisfy time_relation.

Gets timespans:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> timespan = timespantools.Timespan(2, 8)
>>> time_relation = timespantools.timespan_2_starts_during_timespan_1(
...     timespan_1=timespan)
>>> result = timespans.get_timespans_that_satisfy_time_relation(
...     time_relation)
>>> show(result, range_=(0, 10), scale=0.5) 
>>> f(result)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(3, 1),
            stop_offset=durationtools.Offset(6, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(6, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Returns new timespan list.

TimespanList.has_timespan_that_satisfies_time_relation(time_relation)

Is true when timespan list has timespan that satisfies time_relation.

Is true when list has matching timespan:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> timespan = timespantools.Timespan(2, 8)
>>> time_relation = \
...     timespantools.timespan_2_starts_during_timespan_1(
...     timespan_1=timespan)
>>> timespans.has_timespan_that_satisfies_time_relation(
...     time_relation)
True

Is false when list does not have matching timespan:

>>> timespan = timespantools.Timespan(10, 20)
>>> time_relation = \
...     timespantools.timespan_2_starts_during_timespan_1(
...     timespan_1=timespan)
>>> timespans.has_timespan_that_satisfies_time_relation(
...     time_relation)
False

Returns true or false.

(TypedList).index(item)

Gets index of item in typed list.

>>> pitch_list = datastructuretools.TypedList(
...     item_class=NamedPitch,
...     )
>>> pitch_list.extend(['cqf', "as'", 'b,', 'dss'])
>>> pitch_list.index(NamedPitch('cqf'))
0
>>> pitch_list.index(NamedPitch("as'"))
1
>>> pitch_list.index('b,')
2
>>> pitch_list.index('dss')
3

Returns nonnegative integer.

(TypedList).insert(i, item)

Insert item into typed list.

Inserts into typed list.

>>> integer_list = datastructuretools.TypedList(item_class=int)
>>> integer_list.extend(['1', 2, 4.3])
>>> integer_list
TypedList([1, 2, 4], item_class=int)
>>> integer_list.insert(0, '0')
>>> integer_list
TypedList([0, 1, 2, 4], item_class=int)
>>> integer_list.insert(1, '9')
>>> integer_list
TypedList([0, 9, 1, 2, 4], item_class=int)

Returns none.

TimespanList.partition(include_tangent_timespans=False)

Partitions timespans into timespan_lists.

Partitions timespans:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(3, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(3, 1),
            stop_offset=durationtools.Offset(6, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(6, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )
>>> for timespan_list in timespans.partition():
...     f(timespan_list)
...
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(3, 1),
            ),
        ]
    )
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(3, 1),
            stop_offset=durationtools.Offset(6, 1),
            ),
        ]
    )
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(6, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Partitions timespans:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 16),
...     timespantools.Timespan(5, 12),
...     timespantools.Timespan(-2, 8),
...     timespantools.Timespan(15, 20),
...     timespantools.Timespan(24, 30),
...     ])
>>> show(timespans, scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(16, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(5, 1),
            stop_offset=durationtools.Offset(12, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(-2, 1),
            stop_offset=durationtools.Offset(8, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(15, 1),
            stop_offset=durationtools.Offset(20, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(24, 1),
            stop_offset=durationtools.Offset(30, 1),
            ),
        ]
    )
>>> for timespan_list in timespans.partition():
...     f(timespan_list)
...
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(-2, 1),
            stop_offset=durationtools.Offset(8, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(16, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(5, 1),
            stop_offset=durationtools.Offset(12, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(15, 1),
            stop_offset=durationtools.Offset(20, 1),
            ),
        ]
    )
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(24, 1),
            stop_offset=durationtools.Offset(30, 1),
            ),
        ]
    )

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

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> for timespan_list in timespans.partition(
...     include_tangent_timespans=True,
...     ):
...     f(timespan_list)
...
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(3, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(3, 1),
            stop_offset=durationtools.Offset(6, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(6, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Returns zero or more timespan_lists.

(TypedList).pop(i=-1)

Pops item i from typed list.

Returns item.

TimespanList.reflect(axis=None)

Reflects timespans.

Reflects timespans about timespan list axis:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> _ = timespans.reflect()
>>> show(timespans, scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(4, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(4, 1),
            stop_offset=durationtools.Offset(7, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(7, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Reflects timespans about arbitrary axis:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, range_=(0, 30), scale=0.5) 
>>> _ = timespans.reflect(axis=Offset(15))
>>> show(timespans, range_=(0, 30), scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(20, 1),
            stop_offset=durationtools.Offset(24, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(24, 1),
            stop_offset=durationtools.Offset(27, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(27, 1),
            stop_offset=durationtools.Offset(30, 1),
            ),
        ]
    )

Operates in place and returns timespan list.

(TypedList).remove(item)

Removes item from typed list.

>>> integer_list = datastructuretools.TypedList(item_class=int)
>>> integer_list.extend(('0', 1.0, 2, 3.14159))
>>> integer_list[:]
[0, 1, 2, 3]
>>> integer_list.remove('1')
>>> integer_list[:]
[0, 2, 3]

Returns none.

TimespanList.remove_degenerate_timespans()

Removes degenerate timespans.

Removes degenerate timespans:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(5, 5),
...     timespantools.Timespan(5, 10),
...     timespantools.Timespan(5, 25),
...     ])
>>> show(timespans, scale=0.5) 
>>> _ = timespans.remove_degenerate_timespans()
>>> show(timespans, scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(5, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(5, 1),
            stop_offset=durationtools.Offset(25, 1),
            ),
        ]
    )

Operates in place and returns timespan list.

TimespanList.repeat_to_stop_offset(stop_offset)

Repeats timespans to stop_offset.

Repeats timespans to stop offset:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, range_=(0, 15), scale=0.5) 
>>> _ = timespans.repeat_to_stop_offset(15)
>>> show(timespans, range_=(0, 15), scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(3, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(3, 1),
            stop_offset=durationtools.Offset(6, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(6, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(10, 1),
            stop_offset=durationtools.Offset(13, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(13, 1),
            stop_offset=durationtools.Offset(15, 1),
            ),
        ]
    )

Operates in place and returns timespan list.

(TypedList).reverse()

Reverses items in typed list.

TimespanList.rotate(count)

Rotates by count contiguous timespans.

Rotates by one timespan to the left:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 4),
...     timespantools.Timespan(4, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> _ = timespans.rotate(-1)
>>> show(timespans, scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(1, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(1, 1),
            stop_offset=durationtools.Offset(7, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(7, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Rotates by one timespan to the right:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 4),
...     timespantools.Timespan(4, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> _ = timespans.rotate(1)
>>> show(timespans, scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(6, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(6, 1),
            stop_offset=durationtools.Offset(9, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(9, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Operates in place and returns timespan list.

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

Rounds offsets of timespans in list to multiples of multiplier.

Rounds offsets:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 2),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> rounded_timespans = timespans.round_offsets(3)
>>> show(rounded_timespans, range_=(0, 10), scale=0.5) 
>>> f(rounded_timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(3, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(3, 1),
            stop_offset=durationtools.Offset(6, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(6, 1),
            stop_offset=durationtools.Offset(9, 1),
            ),
        ]
    )

Rounds offsets:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 2),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> rounded_timespans = timespans.round_offsets(5)
>>> show(rounded_timespans, scale=0.5) 
>>> f(rounded_timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(5, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(5, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(5, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Rounds offsets:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 2),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, range_=(-5, 10), scale=0.5) 
>>> rounded_timespans = timespans.round_offsets(
...     5,
...     anchor=Right,
...     )
>>> show(rounded_timespans, range_=(-5, 10), scale=0.5) 
>>> f(rounded_timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(-5, 1),
            stop_offset=durationtools.Offset(0, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(5, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(5, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Rounds offsets:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 2),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> rounded_timespans = timespans.round_offsets(
...     5,
...     anchor=Right,
...     must_be_well_formed=False,
...     )
>>> f(rounded_timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(0, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(5, 1),
            stop_offset=durationtools.Offset(5, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(5, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Operates in place and returns timespan list.

TimespanList.scale(multiplier, anchor=Left)

Scales timespan by multiplier relative to anchor.

Scales timespans relative to timespan list start offset:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, range_=(0, 14), scale=0.5) 
>>> _ = timespans.scale(2)
>>> show(timespans, range_=(0, 14), scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(6, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(3, 1),
            stop_offset=durationtools.Offset(9, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(6, 1),
            stop_offset=durationtools.Offset(14, 1),
            ),
        ]
    )

Scales timespans relative to timespan list stop offset:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, range_=(-3, 10), scale=0.5) 
>>> _ = timespans.scale(2, anchor=Right)
>>> show(timespans, range_=(-3, 10), scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(-3, 1),
            stop_offset=durationtools.Offset(3, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(6, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(2, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Operates in place and returns timespan list.

(TypedList).sort(cmp=None, key=None, reverse=False)

Sorts items in typed list.

TimespanList.split_at_offset(offset)

Splits timespans at offset.

Splits at offset:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> left, right = timespans.split_at_offset(4)
>>> show(left, range_=(0, 10), scale=0.5) 
>>> f(left)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(3, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(3, 1),
            stop_offset=durationtools.Offset(4, 1),
            ),
        ]
    )
>>> show(right, range_=(0, 10), scale=0.5) 
>>> f(right)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(4, 1),
            stop_offset=durationtools.Offset(6, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(6, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Splits at offset:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> left, right = timespans.split_at_offset(6)
>>> show(left, range_=(0, 10), scale=0.5) 
>>> f(left)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(3, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(3, 1),
            stop_offset=durationtools.Offset(6, 1),
            ),
        ]
    )
>>> show(right, range_=(0, 10), scale=0.5) 
>>> f(right)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(6, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Splits at offset:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> left, right = timespans.split_at_offset(-1)
>>> left
TimespanList([])
>>> show(right, range_=(0, 10), scale=0.5) 
>>> f(right)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(3, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(3, 1),
            stop_offset=durationtools.Offset(6, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(6, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Returns timespan_lists.

TimespanList.split_at_offsets(offsets)

Splits timespans at offsets.

Splits at offsets:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(4, 10),
...     timespantools.Timespan(15, 20),
...     ])
>>> show(timespans, range_=(0, 20), scale=0.5) 
>>> offsets = [-1, 3, 6, 12, 13]
>>> for timespan_list in timespans.split_at_offsets(offsets):
...     show(timespan_list, range_=(0, 20), scale=0.5) 
...     f(timespan_list)
... 
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(3, 1),
            ),
        ]
    )
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(3, 1),
            stop_offset=durationtools.Offset(6, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(4, 1),
            stop_offset=durationtools.Offset(6, 1),
            ),
        ]
    )
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(6, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(15, 1),
            stop_offset=durationtools.Offset(20, 1),
            ),
        ]
    )

Splits empty list:

>>> timespans = timespantools.TimespanList([])
>>> timespans.split_at_offsets(offsets)
[TimespanList([])]

Returns one or more timespan_lists.

TimespanList.stretch(multiplier, anchor=None)

Stretches timespans by multiplier relative to anchor.

Stretches timespans relative to timespan list start offset:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, range_=(0, 20), scale=0.5) 
>>> _ = timespans.stretch(2)
>>> show(timespans, scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(6, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(6, 1),
            stop_offset=durationtools.Offset(12, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(12, 1),
            stop_offset=durationtools.Offset(20, 1),
            ),
        ]
    )

Stretches timespans relative to arbitrary anchor:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, range_=(-8, 12), scale=0.5) 
>>> _ = timespans.stretch(2, anchor=Offset(8))
>>> show(timespans, scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(-8, 1),
            stop_offset=durationtools.Offset(-2, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(-2, 1),
            stop_offset=durationtools.Offset(4, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(4, 1),
            stop_offset=durationtools.Offset(12, 1),
            ),
        ]
    )

Operates in place and returns timespan list.

TimespanList.translate(translation=None)

Translates timespans by translation.

Translates timespan by offset 50:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, range_=(0, 60), scale=0.5) 
>>> _ = timespans.translate(50)
>>> show(timespans, range_=(0, 60), scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(50, 1),
            stop_offset=durationtools.Offset(53, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(53, 1),
            stop_offset=durationtools.Offset(56, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(56, 1),
            stop_offset=durationtools.Offset(60, 1),
            ),
        ]
    )

Operates in place and returns timespan list.

TimespanList.translate_offsets(start_offset_translation=None, stop_offset_translation=None)

Translates timespans by start_offset_translation and stop_offset_translation.

Translates timespan start- and stop-offsets equally:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, range_=(0, 60), scale=0.5) 
>>> _ = timespans.translate_offsets(50, 50)
>>> show(timespans, range_=(0, 60), scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(50, 1),
            stop_offset=durationtools.Offset(53, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(53, 1),
            stop_offset=durationtools.Offset(56, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(56, 1),
            stop_offset=durationtools.Offset(60, 1),
            ),
        ]
    )

Translates timespan stop-offsets only:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, range_=(0, 30), scale=0.5) 
>>> _ = timespans.translate_offsets(
...     stop_offset_translation=20)
>>> show(timespans, range_=(0, 30), scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(23, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(3, 1),
            stop_offset=durationtools.Offset(26, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(6, 1),
            stop_offset=durationtools.Offset(30, 1),
            ),
        ]
    )

Operates in place and returns timespan list.

Special methods

TimespanList.__and__(timespan)

Keeps material that intersects timespan.

Keeps material that intersects timespan:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 16),
...     timespantools.Timespan(5, 12),
...     timespantools.Timespan(-2, 8),
...     ])
>>> show(timespans, range_=(-2, 12), scale=0.5) 
>>> timespan = timespantools.Timespan(5, 10)
>>> _ = timespans & timespan
>>> show(timespans, range_=(-2, 12), scale=0.5) 
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(5, 1),
            stop_offset=durationtools.Offset(8, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(5, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(5, 1),
            stop_offset=durationtools.Offset(10, 1),
            ),
        ]
    )

Operates in place and returns timespan list.

(TypedCollection).__contains__(item)

Is true when typed collection contains item. Otherwise false.

Returns true or false.

(TypedList).__delitem__(i)

Aliases list.__delitem__().

Returns none.

(TypedCollection).__eq__(argument)

Is true when argument is a typed collection with items that compare equal to those of this typed collection. Otherwise false.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to ‘’ or ‘storage’. Interprets ‘’ equal to ‘storage’.

Returns string.

(TypedList).__getitem__(argument)

Gets item or slice identified by argument.

Returns item or slice.

(TypedCollection).__hash__()

Hashes typed collection.

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

Returns integer.

(TypedList).__iadd__(argument)

Adds argument in place to typed list.

>>> dynamic_list = datastructuretools.TypedList(item_class=Dynamic)
>>> dynamic_list.append('ppp')
>>> dynamic_list += ['p', 'mp', 'mf', 'fff']
>>> f(dynamic_list)
datastructuretools.TypedList(
    [
        indicatortools.Dynamic(
            name='ppp',
            ),
        indicatortools.Dynamic(
            name='p',
            ),
        indicatortools.Dynamic(
            name='mp',
            ),
        indicatortools.Dynamic(
            name='mf',
            ),
        indicatortools.Dynamic(
            name='fff',
            ),
        ],
    item_class=indicatortools.Dynamic,
    )

Returns typed list.

TimespanList.__illustrate__(key=None, range_=None, sortkey=None, scale=None)

Illustrates timespans.

Illustrates timespans:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 16),
...     timespantools.Timespan(5, 12),
...     timespantools.Timespan(-2, 8),
...     ])
>>> show(timespans, scale=0.5) 
>>> timespan_operand = timespantools.Timespan(6, 10)
>>> timespans = timespans - timespan_operand
>>> show(timespans, scale=0.5) 

Returns LilyPond file.

TimespanList.__invert__()

Inverts timespans.

Inverts timespans:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(-2, 8),
...     timespantools.Timespan(15, 20),
...     timespantools.Timespan(24, 30),
...     ])
>>> show(timespans, scale=0.5) 
>>> show(~timespans, range_=(-2, 30), scale=0.5) 
>>> f(~timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(8, 1),
            stop_offset=durationtools.Offset(15, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(20, 1),
            stop_offset=durationtools.Offset(24, 1),
            ),
        ]
    )

Inverts contiguous timespans:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 3),
...     timespantools.Timespan(3, 6),
...     timespantools.Timespan(6, 10),
...     ])
>>> show(timespans, scale=0.5) 
>>> ~timespans
TimespanList([])

Returns new timespan list.

(TypedCollection).__iter__()

Iterates typed collection.

Returns generator.

(TypedCollection).__len__()

Gets length of typed collection.

Returns nonnegative integer.

(TypedCollection).__ne__(argument)

Is true when argument is not a typed collection with items equal to this typed collection. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

(TypedList).__reversed__()

Aliases list.__reversed__().

Returns generator.

(TypedList).__setitem__(i, argument)

Sets item i equal to argument.

Sets item:

>>> pitch_list = datastructuretools.TypedList(
...     item_class=NamedPitch,
...     )
>>> pitch_list.append(0)
>>> pitch_list.append("d'")
>>> pitch_list.append(('e', 4))
>>> pitch_list.append(NamedPitch("f'"))
>>> pitch_list[-1] = 'gqs,'
>>> f(pitch_list)
datastructuretools.TypedList(
    [
        pitchtools.NamedPitch("c'"),
        pitchtools.NamedPitch("d'"),
        pitchtools.NamedPitch("e'"),
        pitchtools.NamedPitch('gqs,'),
        ],
    item_class=pitchtools.NamedPitch,
    )

Sets slice:

>>> pitch_list[-1:] = ["f'", "g'", "a'", "b'", "c''"]
>>> f(pitch_list)
datastructuretools.TypedList(
    [
        pitchtools.NamedPitch("c'"),
        pitchtools.NamedPitch("d'"),
        pitchtools.NamedPitch("e'"),
        pitchtools.NamedPitch("f'"),
        pitchtools.NamedPitch("g'"),
        pitchtools.NamedPitch("a'"),
        pitchtools.NamedPitch("b'"),
        pitchtools.NamedPitch("c''"),
        ],
    item_class=pitchtools.NamedPitch,
    )

Returns none.

TimespanList.__sub__(timespan)

Deletes material that intersects timespan.

Deletes material that intersects timespan:

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 16),
...     timespantools.Timespan(5, 12),
...     timespantools.Timespan(-2, 8),
...     ])
>>> show(timespans, scale=0.5) 
>>> timespan = timespantools.Timespan(5, 10)
>>> _ = timespans - timespan
>>> f(timespans)
timespantools.TimespanList(
    [
        timespantools.Timespan(
            start_offset=durationtools.Offset(-2, 1),
            stop_offset=durationtools.Offset(5, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(0, 1),
            stop_offset=durationtools.Offset(5, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(10, 1),
            stop_offset=durationtools.Offset(12, 1),
            ),
        timespantools.Timespan(
            start_offset=durationtools.Offset(10, 1),
            stop_offset=durationtools.Offset(16, 1),
            ),
        ]
    )
>>> show(timespans, scale=0.5) 

Operates in place and returns timespan list.