NoteHeadList

class scoretools.NoteHeadList(items=None, client=None)

An ordered list of note-heads.

>>> chord = Chord([0, 1, 4], (1, 4))
>>> note_heads = scoretools.NoteHeadList(
...     client=chord,
...     items=[11, 10, 9],
...     )
>>> f(note_heads)
scoretools.NoteHeadList(
    [
        scoretools.NoteHead(
            written_pitch=pitchtools.NamedPitch("a'"),
            ),
        scoretools.NoteHead(
            written_pitch=pitchtools.NamedPitch("bf'"),
            ),
        scoretools.NoteHead(
            written_pitch=pitchtools.NamedPitch("b'"),
            ),
        ]
    )

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

Attribute summary

append(item) Appends item to typed list.
client Gets client.
count(item) Gets count of item in typed list.
extend(items) Extends note-heads.
get(pitch) Gets note-head by pitch.
index(item) Gets index of item in typed list.
insert(i, item) Insert item into typed list.
item_class Gets item class of collection.
items Gets items in collection.
keep_sorted Is true when typed list keeps items sorted.
pop([i]) Pops note-head i.
remove(item) Removes item.
reverse() Reverses items in typed list.
sort([cmp, key, reverse]) Sorts items in typed list.
__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.
__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.

Read-only properties

NoteHeadList.client

Gets client.

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

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.

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

NoteHeadList.extend(items)

Extends note-heads.

>>> chord = Chord("<ef'>")
>>> show(chord) 
>>> note_heads = []
>>> note_head = scoretools.NoteHead("cs''")
>>> note_head.tweak.color = 'blue'
>>> note_heads.append(note_head)
>>> note_head = scoretools.NoteHead("f''")
>>> note_head.tweak.color = 'green'
>>> note_heads.append(note_head)
>>> chord.note_heads.extend(note_heads)
>>> show(chord) 

Returns note-head.

NoteHeadList.get(pitch)

Gets note-head by pitch.

Gets note-head by pitch name:

>>> chord = Chord("<e' cs'' f''>4")
>>> show(chord) 
>>> note_head = chord.note_heads.get("e'")
>>> note_head.tweak.color = 'red'
>>> show(chord) 

Gets note-head by pitch number:

>>> chord = Chord("<e' cs'' f''>4")
>>> show(chord) 
>>> note_head = chord.note_heads.get(4)
>>> note_head.tweak.color = 'red'
>>> show(chord) 

Raises missing note-head error when chord contains no note-head with pitch.

Raises extra note-head error when chord contains more than one note-head with pitch.

Returns note-head.

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

NoteHeadList.pop(i=-1)

Pops note-head i.

>>> chord = Chord("<ef' c'' f''>4")
>>> show(chord) 
>>> chord.note_heads.pop(1)
NoteHead("c''")
>>> show(chord) 

Returns note-head.

NoteHeadList.remove(item)

Removes item.

>>> chord = Chord("<ef' c'' f''>4")
>>> show(chord) 
>>> note_head = chord.note_heads[1]
>>> chord.note_heads.remove(note_head)
>>> show(chord) 
(TypedList).reverse()

Reverses items in typed list.

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

Sorts items in typed list.

Special methods

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

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