PitchClassVector

class pitchtools.PitchClassVector(items=None, item_class=None)

Pitch-class vector.

>>> import abjad

Pitch-class vector:

>>> vector = abjad.PitchClassVector(
...     items=[7, 6, -2, -3, -3, 0, 1, 14, 15, 16, 16],
...     item_class=abjad.NumberedPitchClass,
...     )
>>> items = sorted(vector.items())
>>> for pitch_class, count in items:
...     print(pitch_class, count)
0 1
1 1
2 1
3 1
4 2
6 1
7 1
9 2
10 1

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_pitchtools { graph [label=pitchtools]; "abjad.tools.pitchtools.PitchClassVector.PitchClassVector" [color=black, fontcolor=white, group=3, label=<<B>PitchClassVector</B>>, shape=box, style="filled, rounded"]; "abjad.tools.pitchtools.Vector.Vector" [color=4, group=3, label=Vector, shape=oval, style=bold]; "abjad.tools.pitchtools.Vector.Vector" -> "abjad.tools.pitchtools.PitchClassVector.PitchClassVector"; } 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.pitchtools.Vector.Vector"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Attribute summary

clear() Clears typed counter.
copy() Copies typed counter.
elements() Elements in typed counter.
from_selection(selection[, item_class]) Makes pitch-class vector from selection.
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]) Gets format of pitch-class vector.
__getitem__(argument) Gets item or slice identified by argument.
__hash__() Hashes typed collection.
__iter__() Iterates typed collection.
__len__() Gets length of typed collection.
__ne__(argument) Is true when Abjad object does not equal argument.
__or__(argument) Logical OR of typed counter and argument.
__radd__(argument) Adds argument to typed counter.
__repr__() Gets interpreter representation of pitch-class vector.
__setitem__(item, value) Sets typed counter item to value.
__str__() String representation of vector.
__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.

Class & static methods

classmethod PitchClassVector.from_selection(selection, item_class=None)

Makes pitch-class vector from selection.

Returns pitch-class vector.

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.

PitchClassVector.__format__(format_specification='')

Gets format of pitch-class vector.

>>> vector = abjad.PitchClassVector(
...     items=[7, 6, -2, -3, -3, 0, 1, 14, 15, 16, 16],
...     item_class=abjad.NumberedPitchClass,
...     )
>>> f(vector)
abjad.PitchClassVector(
    {
        abjad.NumberedPitchClass(0): 1,
        abjad.NumberedPitchClass(1): 1,
        abjad.NumberedPitchClass(2): 1,
        abjad.NumberedPitchClass(3): 1,
        abjad.NumberedPitchClass(4): 2,
        abjad.NumberedPitchClass(6): 1,
        abjad.NumberedPitchClass(7): 1,
        abjad.NumberedPitchClass(9): 2,
        abjad.NumberedPitchClass(10): 1,
        },
    item_class=abjad.NumberedPitchClass,
    )

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.

(TypedCollection).__iter__()

Iterates typed collection.

Returns generator.

(TypedCollection).__len__()

Gets length of typed collection.

Returns nonnegative integer.

(AbjadObject).__ne__(argument)

Is true when Abjad object does not equal argument. Otherwise false.

Returns true or false.

(TypedCounter).__or__(argument)

Logical OR of typed counter and argument.

Returns new typed counter.

(TypedCounter).__radd__(argument)

Adds argument to typed counter.

Returns new typed counter.

PitchClassVector.__repr__()

Gets interpreter representation of pitch-class vector.

Gets interpreter representation of pitch-class vector:

>>> vector = abjad.PitchClassVector(
...     items=[7, 6, -2, -3, -3, 0, 1, 14, 15, 16, 16],
...     item_class=abjad.NumberedPitchClass,
...     )
>>> vector
PitchClassVector({0: 1, 1: 1, 2: 1, 3: 1, 4: 2, 6: 1, 7: 1, 9: 2, 10: 1}, item_class=NumberedPitchClass)

Initializes from interpreter representation of pitch-class vector:

>>> abjad.PitchClassVector(vector)
PitchClassVector({0: 1, 1: 1, 2: 1, 3: 1, 4: 2, 6: 1, 7: 1, 9: 2, 10: 1}, item_class=NumberedPitchClass)

Returns string.

(TypedCounter).__setitem__(item, value)

Sets typed counter item to value.

Returns none.

(Vector).__str__()

String representation of vector.

Returns string.

(TypedCounter).__sub__(argument)

Subtracts argument from typed counter.

Returns new typed counter.