PerformerInventory

class instrumenttools.PerformerInventory(items=None, item_class=None, keep_sorted=False)

Abjad model of an ordered list of performers.

Performer inventories implement the list interface and are mutable.

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_instrumenttools { graph [label=instrumenttools]; "abjad.tools.instrumenttools.PerformerInventory.PerformerInventory" [color=black, fontcolor=white, group=3, label=<<B>PerformerInventory</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.instrumenttools.PerformerInventory.PerformerInventory"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Attribute summary

append(item) Changes item to item and appends.
count(item) Changes item to item and returns count.
extend(items) Changes items to items and extends.
get_instrument(instrument_name) Gets first instrument in performer inventory with instrument_name.
index(item) Changes item to item and returns index.
insert(i, item) Changes item to item and inserts.
item_class Item class to coerce items into.
items Gets collection items.
keep_sorted Sorts collection on mutation if true.
pop([i]) Aliases list.pop().
remove(item) Changes item to item and removes.
reverse() Aliases list.reverse().
sort([cmp, key, reverse]) Aliases list.sort().
__contains__(item) Is true when typed collection container item.
__delitem__(i) Aliases list.__delitem__().
__eq__(expr) Is true when expr is a typed collection with items that compare equal to those of this typed collection.
__format__([format_specification]) Formats Abjad object.
__getitem__(i) Aliases list.__getitem__().
__hash__() Hashes typed collection.
__iadd__(expr) Changes items in expr to items and extends.
__iter__() Iterates typed collection.
__len__() Length of typed collection.
__ne__(expr) Is true when expr 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, expr) Changes items in expr to items and sets.

Read-only properties

(TypedCollection).item_class

Item class to coerce items into.

(TypedCollection).items

Gets collection items.

Read/write properties

(TypedList).keep_sorted

Sorts collection on mutation if true.

Methods

(TypedList).append(item)

Changes item to item and appends.

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

Returns none.

(TypedList).count(item)

Changes item to item and returns count.

>>> integer_collection = datastructuretools.TypedList(
...     items=[0, 0., '0', 99],
...     item_class=int)
>>> integer_collection[:]
[0, 0, 0, 99]
>>> integer_collection.count(0)
3

Returns count.

(TypedList).extend(items)

Changes items to items and extends.

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

Returns none.

PerformerInventory.get_instrument(instrument_name)

Gets first instrument in performer inventory with instrument_name.

>>> flutist = instrumenttools.Performer(name='flutist')
>>> flutist.instruments.append(instrumenttools.Flute())
>>> flutist.instruments.append(instrumenttools.Piccolo())
>>> inventory = instrumenttools.PerformerInventory(
...     [flutist],
...     )
>>> inventory.get_instrument('piccolo')
Piccolo()

Returns instrument or none.

(TypedList).index(item)

Changes item to item and returns index.

>>> pitch_collection = datastructuretools.TypedList(
...     items=('cqf', "as'", 'b,', 'dss'),
...     item_class=NamedPitch)
>>> pitch_collection.index("as'")
1

Returns index.

(TypedList).insert(i, item)

Changes item to item and inserts.

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

Returns none.

(TypedList).pop(i=-1)

Aliases list.pop().

(TypedList).remove(item)

Changes item to item and removes.

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

Returns none.

(TypedList).reverse()

Aliases list.reverse().

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

Aliases list.sort().

Special methods

(TypedCollection).__contains__(item)

Is true when typed collection container item. Otherwise false.

Returns true or false.

(TypedList).__delitem__(i)

Aliases list.__delitem__().

Returns none.

(TypedCollection).__eq__(expr)

Is true when expr 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__(i)

Aliases list.__getitem__().

Returns item.

(TypedCollection).__hash__()

Hashes typed collection.

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

Returns integer.

(TypedList).__iadd__(expr)

Changes items in expr to items and extends.

>>> dynamic_collection = datastructuretools.TypedList(
...     item_class=Dynamic)
>>> dynamic_collection.append('ppp')
>>> dynamic_collection += ['p', 'mp', 'mf', 'fff']
>>> print(format(dynamic_collection))
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 collection.

(TypedCollection).__iter__()

Iterates typed collection.

Returns generator.

(TypedCollection).__len__()

Length of typed collection.

Returns nonnegative integer.

(TypedCollection).__ne__(expr)

Is true when expr 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, expr)

Changes items in expr to items and sets.

>>> pitch_collection[-1] = 'gqs,'
>>> print(format(pitch_collection))
datastructuretools.TypedList(
    [
        pitchtools.NamedPitch("c'"),
        pitchtools.NamedPitch("d'"),
        pitchtools.NamedPitch("e'"),
        pitchtools.NamedPitch('gqs,'),
        ],
    item_class=pitchtools.NamedPitch,
    )
>>> pitch_collection[-1:] = ["f'", "g'", "a'", "b'", "c''"]
>>> print(format(pitch_collection))
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.