PitchClassVector

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.pitch" { graph [label="abjad.pitch"]; node [color=1]; "abjad.pitch.PitchClassVector.PitchClassVector" [URL="../api/abjad/pitch/PitchClassVector.html#abjad.pitch.PitchClassVector.PitchClassVector", color=black, fontcolor=white, label="Pitch\nClass\nVector", target=_top]; "abjad.pitch.Vector.Vector" [URL="../api/abjad/pitch/Vector.html#abjad.pitch.Vector.Vector", label=Vector, shape=oval, style=bold, target=_top]; "abjad.pitch.Vector.Vector" -> "abjad.pitch.PitchClassVector.PitchClassVector"; } subgraph "cluster_abjad.system" { graph [label="abjad.system"]; node [color=2]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/pitch/../system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; } subgraph "cluster_abjad.utilities" { graph [label="abjad.utilities"]; node [color=3]; "abjad.utilities.TypedCollection.TypedCollection" [URL="../api/abjad/pitch/../utilities/TypedCollection.html#abjad.utilities.TypedCollection.TypedCollection", label="Typed\nCollection", shape=oval, style=bold, target=_top]; "abjad.utilities.TypedCounter.TypedCounter" [URL="../api/abjad/pitch/../utilities/TypedCounter.html#abjad.utilities.TypedCounter.TypedCounter", label="Typed\nCounter", target=_top]; "abjad.utilities.TypedCollection.TypedCollection" -> "abjad.utilities.TypedCounter.TypedCounter"; } subgraph cluster_builtins { graph [label=builtins]; node [color=4]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } subgraph "cluster_collections.abc" { graph [label="collections.abc"]; node [color=5]; "collections.abc.Collection" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Collection", label=Collection, shape=oval, style=bold, target=_top]; "collections.abc.Container" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Container", label=Container, shape=oval, style=bold, target=_top]; "collections.abc.Iterable" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Iterable", label=Iterable, shape=oval, style=bold, target=_top]; "collections.abc.Mapping" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Mapping", label=Mapping, shape=oval, style=bold, target=_top]; "collections.abc.MutableMapping" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.MutableMapping", label="Mutable\nMapping", shape=oval, style=bold, target=_top]; "collections.abc.Sized" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Sized", label=Sized, shape=oval, style=bold, target=_top]; "collections.abc.Collection" -> "collections.abc.Mapping"; "collections.abc.Container" -> "collections.abc.Collection"; "collections.abc.Iterable" -> "collections.abc.Collection"; "collections.abc.Mapping" -> "collections.abc.MutableMapping"; "collections.abc.Sized" -> "collections.abc.Collection"; } "abjad.system.AbjadObject.AbjadObject" -> "abjad.utilities.TypedCollection.TypedCollection"; "abjad.utilities.TypedCounter.TypedCounter" -> "abjad.pitch.Vector.Vector"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; "builtins.object" -> "collections.abc.Container"; "builtins.object" -> "collections.abc.Iterable"; "builtins.object" -> "collections.abc.Sized"; "collections.abc.MutableMapping" -> "abjad.utilities.TypedCounter.TypedCounter"; }

class abjad.pitch.PitchClassVector.PitchClassVector(items=None, item_class=None)

Pitch-class vector.

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

Attributes Summary

__format__ Gets format of pitch-class vector.
__repr__ Gets interpreter representation of pitch-class vector.
from_selection Makes pitch-class vector from selection.

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.

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.

Returns true or false.

__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,
...     )
>>> abjad.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.

Redefined in tandem with __eq__.

(TypedCollection).__iter__()

Iterates typed collection.

Returns generator.

(TypedCollection).__len__()

Gets length of typed collection.

Returns nonnegative integer.

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

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


Methods

(TypedCounter).clear()

Clears typed counter.

Returns none.

(TypedCounter).copy()

Copies typed counter.

Returns new typed counter.

(TypedCounter).elements()

Elements in typed counter.

(Mapping).get(k[, d]) → D[k] if k in D, else d. d defaults to None.
(TypedCounter).items()

Items in typed counter.

Returns tuple.

(TypedCounter).keys()

Iterates keys in typed counter.

(TypedCounter).most_common(n=None)

Please document.

(MutableMapping).pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

(MutableMapping).popitem() → (k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

(MutableMapping).setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D
(TypedCounter).subtract(iterable=None, **keywords)

Subtracts 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 from_selection(selection, item_class=None)

Makes pitch-class vector from selection.

Returns pitch-class vector.


Read-only properties

(TypedCollection).item_class

Gets item class of collection.

Collection coerces items according to item_class.

Returns class.