OffsetCounter

class metertools.OffsetCounter(items=None)

An offset counter.

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 16),
...     timespantools.Timespan(5, 12),
...     timespantools.Timespan(-2, 8),
...     ])
>>> timespan_operand = timespantools.Timespan(6, 10)
>>> timespans = timespans - timespan_operand
>>> offset_counter = metertools.OffsetCounter(timespans)
>>> f(offset_counter)
metertools.OffsetCounter(
    {
        durationtools.Offset(-2, 1): 1,
        durationtools.Offset(0, 1): 1,
        durationtools.Offset(5, 1): 1,
        durationtools.Offset(6, 1): 3,
        durationtools.Offset(10, 1): 2,
        durationtools.Offset(12, 1): 1,
        durationtools.Offset(16, 1): 1,
        }
    )
>>> show(offset_counter, scale=0.5) 

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.TypedCounter.TypedCounter" [color=3, group=2, label=TypedCounter, shape=box]; "abjad.tools.datastructuretools.TypedCollection.TypedCollection" -> "abjad.tools.datastructuretools.TypedCounter.TypedCounter"; } subgraph cluster_metertools { graph [label=metertools]; "abjad.tools.metertools.OffsetCounter.OffsetCounter" [color=black, fontcolor=white, group=3, label=<<B>OffsetCounter</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.TypedCounter.TypedCounter" -> "abjad.tools.metertools.OffsetCounter.OffsetCounter"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Attribute summary

clear() Clears typed counter.
copy() Copies typed counter.
elements() Elements in typed counter.
item_class Gets item class of collection.
items() Items in typed counter.
keys() Iterates keys in typed counter.
most_common([n]) Please document.
subtract([iterable]) Stracts iterable from typed counter.
update([iterable]) Updates typed counter with iterable.
values() Iterates values in typed counter.
viewitems() Please document.
viewkeys() Please document.
viewvalues() Please document.
__add__(argument) Adds typed counter to argument.
__and__(argument) Logical AND of typed counter and argument.
__contains__(item) Is true when typed collection contains item.
__delitem__(item) Deletes item from typed counter.
__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.
__illustrate__([range_, scale]) Illustrates offset counter.
__iter__() Iterates typed collection.
__len__() Gets length of typed collection.
__missing__(item) Returns zero.
__ne__(argument) Is true when argument is not a typed collection with items equal to this typed collection.
__or__(argument) Logical OR of typed counter and argument.
__repr__() Gets interpreter representation of Abjad object.
__setitem__(item, value) Sets typed counter item to value.
__sub__(argument) Subtracts argument from typed counter.

Read-only properties

(TypedCollection).item_class

Gets item class of collection.

Collection coerces items according to item_class.

Returns class.

Methods

(TypedCounter).clear()

Clears typed counter.

Returns none.

(TypedCounter).copy()

Copies typed counter.

Returns new typed counter.

(TypedCounter).elements()

Elements in typed counter.

(TypedCounter).items()

Items in typed counter.

Returns tuple.

(TypedCounter).keys()

Iterates keys in typed counter.

(TypedCounter).most_common(n=None)

Please document.

(TypedCounter).subtract(iterable=None, **keywords)

Stracts iterable from typed counter.

(TypedCounter).update(iterable=None, **keywords)

Updates typed counter with iterable.

(TypedCounter).values()

Iterates values in typed counter.

(TypedCounter).viewitems()

Please document.

(TypedCounter).viewkeys()

Please document.

(TypedCounter).viewvalues()

Please document.

Special methods

(TypedCounter).__add__(argument)

Adds typed counter to argument.

Returns new typed counter.

(TypedCounter).__and__(argument)

Logical AND of typed counter and argument.

Returns new typed counter.

(TypedCollection).__contains__(item)

Is true when typed collection contains item. Otherwise false.

Returns true or false.

(TypedCounter).__delitem__(item)

Deletes item from typed counter.

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.

(TypedCounter).__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.

OffsetCounter.__illustrate__(range_=None, scale=None)

Illustrates offset counter.

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

Returns LilyPond file.

(TypedCollection).__iter__()

Iterates typed collection.

Returns generator.

(TypedCollection).__len__()

Gets length of typed collection.

Returns nonnegative integer.

(TypedCounter).__missing__(item)

Returns zero.

Returns zero.

(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.

(TypedCounter).__or__(argument)

Logical OR of typed counter and argument.

Returns new typed counter.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

(TypedCounter).__setitem__(item, value)

Sets typed counter item to value.

Returns none.

(TypedCounter).__sub__(argument)

Subtracts argument from typed counter.

Returns new typed counter.