pcollections

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_builtins { graph [label=builtins]; node [color=2]; "builtins.frozenset" [URL="https://docs.python.org/3.10/library/stdtypes.html#frozenset", label=frozenset, target=_top]; "builtins.object" [URL="https://docs.python.org/3.10/library/functions.html#object", label=object, target=_top]; "builtins.object" -> "builtins.frozenset"; } subgraph "cluster_abjad.pcollections" { graph [label="abjad.pcollections"]; node [color=1]; "abjad.pcollections.PitchClassSegment" [URL="../api/abjad/pcollections.html#abjad.pcollections.PitchClassSegment", color=black, fontcolor=white, label="Pitch\nClass\nSegment", target=_top]; "abjad.pcollections.TwelveToneRow" [URL="../api/abjad/pcollections.html#abjad.pcollections.TwelveToneRow", color=black, fontcolor=white, label="Twelve\nTone\nRow", target=_top]; "abjad.pcollections.PitchClassSegment" -> "abjad.pcollections.TwelveToneRow" [minlen=1]; "abjad.pcollections.PitchClassSet" [URL="../api/abjad/pcollections.html#abjad.pcollections.PitchClassSet", color=black, fontcolor=white, label="Pitch\nClass\nSet", target=_top]; "abjad.pcollections.PitchRange" [URL="../api/abjad/pcollections.html#abjad.pcollections.PitchRange", color=black, fontcolor=white, label="Pitch\nRange", target=_top]; "abjad.pcollections.PitchSegment" [URL="../api/abjad/pcollections.html#abjad.pcollections.PitchSegment", color=black, fontcolor=white, label="Pitch\nSegment", target=_top]; "abjad.pcollections.PitchSet" [URL="../api/abjad/pcollections.html#abjad.pcollections.PitchSet", color=black, fontcolor=white, label="Pitch\nSet", target=_top]; } "builtins.frozenset" -> "abjad.pcollections.PitchClassSet" [minlen=1]; "builtins.frozenset" -> "abjad.pcollections.PitchSet" [minlen=2]; "builtins.object" -> "abjad.pcollections.PitchClassSegment" [minlen=1]; "builtins.object" -> "abjad.pcollections.PitchRange" [minlen=2]; "builtins.object" -> "abjad.pcollections.PitchSegment" [minlen=1]; }


Classes

PitchClassSegment

Numbered pitch-class segment.

PitchClassSet

Numbered pitch-class set.

PitchRange

Pitch range.

PitchSegment

Named pitch segment.

PitchSet

Numbered pitch set.

TwelveToneRow

Twelve-tone row.

class abjad.pcollections.PitchClassSegment(items=())[source]

Numbered pitch-class segment.

>>> segment = abjad.PitchClassSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> segment
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> lilypond_file = abjad.illustrate(segment)
>>> abjad.show(lilypond_file)  

Attributes Summary

__add__

Adds argument to numbered pitch-class segment.

__contains__

Is true when numbered pitch-class segment contains argument.

__eq__

Return self==value.

__getitem__

Gets argument from numbered pitch-class segment.

__iter__

Iterates numbered pitch-class segment.

__len__

Gets length of numbered pitch-class segment.

__mul__

Multiplies numbered pitch-class segment by n.

__post_init__

__repr__

Gets repr.

__rmul__

Multiplies n by numbered pitch-class segment.

__str__

Gets string representation of numbered pitch-class segment.

invert

Inverts numbered pitch-class segment.

multiply

Multiplies pitch-classes in numbered pitch-class segment by n.

retrograde

Gets retrograde of numbered pitch-class segment.

rotate

Rotates numbered pitch-class segment by index n.

transpose

Transposes numbered pitch-class segment by index n.


Special methods

__add__(argument)[source]

Adds argument to numbered pitch-class segment.

Return type:

PitchClassSegment

__contains__(argument)[source]

Is true when numbered pitch-class segment contains argument.

Return type:

bool

overridden __eq__(other)

Return self==value.

__getitem__(argument)[source]

Gets argument from numbered pitch-class segment.

__iter__()[source]

Iterates numbered pitch-class segment.

__len__()[source]

Gets length of numbered pitch-class segment.

__mul__(n)[source]

Multiplies numbered pitch-class segment by n.

>>> segment = abjad.PitchClassSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> 2 * segment
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7, 10, 10.5, 6, 7, 10.5, 7])
Return type:

PitchClassSegment

__post_init__()[source]
overridden __repr__()[source]

Gets repr.

Return type:

str

__rmul__(n)[source]

Multiplies n by numbered pitch-class segment.

>>> segment = abjad.PitchClassSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> segment * 2
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7, 10, 10.5, 6, 7, 10.5, 7])
Return type:

PitchClassSegment

overridden __str__()[source]

Gets string representation of numbered pitch-class segment.

>>> segment = abjad.PitchClassSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> str(segment)
'PC<10, 10.5, 6, 7, 10.5, 7>'
Return type:

str


Methods

invert(axis=None)[source]

Inverts numbered pitch-class segment.

>>> segment = abjad.PitchClassSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> segment.invert()
PitchClassSegment([2, 1.5, 6, 5, 1.5, 5])
>>> segment.invert().invert()
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
Return type:

PitchClassSegment

multiply(n=1)[source]

Multiplies pitch-classes in numbered pitch-class segment by n.

>>> segment = abjad.PitchClassSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> segment
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> segment.multiply(n=1)
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> segment.multiply(n=5)
PitchClassSegment([2, 4.5, 6, 11, 4.5, 11])
>>> segment.multiply(n=7)
PitchClassSegment([10, 1.5, 6, 1, 1.5, 1])
>>> segment.multiply(n=99)
PitchClassSegment([6, 7.5, 6, 9, 7.5, 9])
Return type:

PitchClassSegment

retrograde()[source]

Gets retrograde of numbered pitch-class segment.

>>> segment = abjad.PitchClassSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> segment.retrograde()
PitchClassSegment([7, 10.5, 7, 6, 10.5, 10])
>>> segment.retrograde().retrograde()
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
Return type:

PitchClassSegment

rotate(n=0)[source]

Rotates numbered pitch-class segment by index n.

>>> segment = abjad.PitchClassSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> segment.rotate(n=1)
PitchClassSegment([7, 10, 10.5, 6, 7, 10.5])
>>> segment.rotate(n=-1)
PitchClassSegment([10.5, 6, 7, 10.5, 7, 10])
>>> segment.rotate(n=0)
PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
Return type:

PitchClassSegment

transpose(n=0)[source]

Transposes numbered pitch-class segment by index n.

>>> segment = abjad.PitchClassSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> segment.transpose(n=11)
PitchClassSegment([9, 9.5, 5, 6, 9.5, 6])
Return type:

PitchClassSegment

class abjad.pcollections.PitchClassSet(argument=())[source]

Numbered pitch-class set.

>>> set_ = abjad.PitchClassSet([-2, -1.5, 6, 7, -1.5, 7])
>>> set_
PitchClassSet([6, 7, 10, 10.5])
>>> str(set_)
'PC{6, 7, 10, 10.5}'
>>> abjad.NamedPitch("fs") in set_
False
>>> abjad.NamedPitch("f") in set_
False
>>> 6 in set_
False
>>> 5 in set_
False
>>> abjad.NumberedPitchClass(5) in set_
False
>>> abjad.NumberedPitchClass(6) in set_
True

Classical operators:

>>> set_1 = abjad.PitchClassSet([0, 2, 4, 5])
>>> set_2 = abjad.PitchClassSet([4, 5, 9])
>>> set_1 & set_2
PitchClassSet([4, 5])
>>> set_1 | set_2
PitchClassSet([0, 2, 4, 5, 9])
>>> set_1 ^ set_2
PitchClassSet([0, 2, 9])
>>> set_1 - set_2
PitchClassSet([0, 2])
>>> set_2 - set_1
PitchClassSet([9])

Attributes Summary

__and__

Return self&value.

__new__

__or__

Return self|value.

__repr__

Return repr(self).

__str__

Return str(self).

__sub__

Return self-value.

__xor__

Return self^value.

cardinality

difference

Return the difference of two or more sets as a new set.

get_normal_order

Gets normal order.

get_prime_form

Gets prime form.

intersection

Return the intersection of two sets as a new set.

invert

Inverts pitch-class set.

multiply

Multiplies pitch-class set by n.

symmetric_difference

Return the symmetric difference of two sets as a new set.

transpose

Transposes all pitch-classes in pitch-class set by index n.

union

Return the union of sets as a new set.


Special methods

overridden __and__(*arguments)

Return self&value.

(frozenset).__class_getitem__()

See PEP 585

(frozenset).__contains__()

x.__contains__(y) <==> y in x.

(frozenset).__eq__(value, /)

Return self==value.

(frozenset).__ge__(value, /)

Return self>=value.

(frozenset).__gt__(value, /)

Return self>value.

(frozenset).__hash__()

Return hash(self).

(frozenset).__iter__()

Implement iter(self).

(frozenset).__le__(value, /)

Return self<=value.

(frozenset).__len__()

Return len(self).

(frozenset).__lt__(value, /)

Return self<value.

(frozenset).__ne__(value, /)

Return self!=value.

overridden static __new__(class_, argument=())[source]
overridden __or__(*arguments)

Return self|value.

(frozenset).__rand__(value, /)

Return value&self.

overridden __repr__()[source]

Return repr(self).

(frozenset).__ror__(value, /)

Return value|self.

(frozenset).__rsub__(value, /)

Return value-self.

(frozenset).__rxor__(value, /)

Return value^self.

overridden __str__()[source]

Return str(self).

Return type:

str

overridden __sub__(*arguments)

Return self-value.

overridden __xor__(*arguments)

Return self^value.


Methods

(frozenset).copy()

Return a shallow copy of a set.

overridden difference(*arguments)

Return the difference of two or more sets as a new set.

(i.e. all elements that are in this set but not the others.)

get_normal_order()[source]

Gets normal order.

Gets normal order of empty pitch-class set:

>>> pc_set = abjad.PitchClassSet()
>>> pc_set.get_normal_order()
PitchClassSegment([])

Gets normal order:

>>> pc_set = abjad.PitchClassSet([0, 1, 10, 11])
>>> pc_set.get_normal_order()
PitchClassSegment([10, 11, 0, 1])

Gets normal order:

>>> pc_set = abjad.PitchClassSet([2, 8, 9])
>>> pc_set.get_normal_order()
PitchClassSegment([8, 9, 2])

Gets normal order of pitch-class set with degree of symmetry equal to 2:

>>> pc_set = abjad.PitchClassSet([1, 2, 7, 8])
>>> pc_set.get_normal_order()
PitchClassSegment([1, 2, 7, 8])

Gets normal order of pitch-class set with degree of symmetry equal to 4:

>>> pc_set = abjad.PitchClassSet([0, 3, 6, 9])
>>> pc_set.get_normal_order()
PitchClassSegment([0, 3, 6, 9])
Return type:

PitchClassSegment

get_prime_form(transposition_only=False)[source]

Gets prime form.

Gets prime form of empty pitch-class set:

>>> pc_set = abjad.PitchClassSet()
>>> pc_set.get_prime_form()
PitchClassSet([])
>>> pc_set = abjad.PitchClassSet()
>>> pc_set.get_prime_form(transposition_only=True)
PitchClassSet([])

Gets prime form:

>>> pc_set = abjad.PitchClassSet([0, 1, 10, 11])
>>> pc_set.get_prime_form()
PitchClassSet([0, 1, 2, 3])
>>> pc_set = abjad.PitchClassSet([0, 1, 10, 11])
>>> pc_set.get_prime_form(transposition_only=True)
PitchClassSet([0, 1, 2, 3])

Gets prime form:

>>> pc_set = abjad.PitchClassSet([2, 8, 9])
>>> pc_set.get_prime_form()
PitchClassSet([0, 1, 6])
>>> pc_set = abjad.PitchClassSet([2, 8, 9])
>>> pc_set.get_prime_form(transposition_only=True)
PitchClassSet([0, 1, 6])

Gets prime form of pitch-class set with degree of symmetry equal to 2:

>>> pc_set = abjad.PitchClassSet([1, 2, 7, 8])
>>> pc_set.get_prime_form()
PitchClassSet([0, 1, 6, 7])
>>> pc_set = abjad.PitchClassSet([1, 2, 7, 8])
>>> pc_set.get_prime_form(transposition_only=True)
PitchClassSet([0, 1, 6, 7])

Gets prime form of pitch-class set with degree of symmetry equal to 4:

>>> pc_set = abjad.PitchClassSet([0, 3, 6, 9])
>>> pc_set.get_prime_form()
PitchClassSet([0, 3, 6, 9])
>>> pc_set = abjad.PitchClassSet([0, 3, 6, 9])
>>> pc_set.get_prime_form(transposition_only=True)
PitchClassSet([0, 3, 6, 9])

Gets prime form of pitch-class that is not inversion-equivalent:

>>> pc_set = abjad.PitchClassSet([0, 4, 6, 7])
>>> pc_set.get_prime_form()
PitchClassSet([0, 1, 3, 7])
>>> pc_set = abjad.PitchClassSet([0, 4, 6, 7])
>>> pc_set.get_prime_form(transposition_only=True)
PitchClassSet([0, 4, 6, 7])

Gets prime form of inversionally nonequivalent pitch-class set:

>>> pc_set = abjad.PitchClassSet([0, 4, 7])
>>> pc_set.get_prime_form()
PitchClassSet([0, 3, 7])
>>> pc_set = abjad.PitchClassSet([0, 4, 7])
>>> pc_set.get_prime_form(transposition_only=True)
PitchClassSet([0, 4, 7])

REGRESSION:

>>> pc_set = abjad.PitchClassSet([0, 1, 2, 5, 8, 9])
>>> pc_set.get_prime_form()
PitchClassSet([0, 1, 2, 5, 6, 9])

REGRESSION:

>>> pc_set = abjad.PitchClassSet([0, 1, 2, 3, 6, 7])
>>> pc_set.get_prime_form()
PitchClassSet([0, 1, 2, 3, 6, 7])

Returns new pitch-class set.

Return type:

PitchClassSet

overridden intersection(*arguments)

Return the intersection of two sets as a new set.

(i.e. all elements that are in both sets.)

invert(axis=None)[source]

Inverts pitch-class set.

>>> abjad.PitchClassSet([-2, -1.5, 6, 7, -1.5, 7]).invert()
PitchClassSet([1.5, 2, 5, 6])
Return type:

PitchClassSet

(frozenset).isdisjoint()

Return True if two sets have a null intersection.

(frozenset).issubset()

Report whether another set contains this set.

(frozenset).issuperset()

Report whether this set contains another set.

multiply(n)[source]

Multiplies pitch-class set by n.

>>> abjad.PitchClassSet([-2, -1.5, 6, 7, -1.5, 7]).multiply(5)
PitchClassSet([2, 4.5, 6, 11])
Return type:

PitchClassSet

overridden symmetric_difference(*arguments)

Return the symmetric difference of two sets as a new set.

(i.e. all elements that are in exactly one of the sets.)

transpose(n=0)[source]

Transposes all pitch-classes in pitch-class set by index n.

>>> set_ = abjad.PitchClassSet([-2, -1.5, 6, 7, -1.5, 7])
>>> for n in range(12):
...     print(n, set_.transpose(n))
... 
0 PC{6, 7, 10, 10.5}
1 PC{7, 8, 11, 11.5}
2 PC{0, 0.5, 8, 9}
3 PC{1, 1.5, 9, 10}
4 PC{2, 2.5, 10, 11}
5 PC{0, 3, 3.5, 11}
6 PC{0, 1, 4, 4.5}
7 PC{1, 2, 5, 5.5}
8 PC{2, 3, 6, 6.5}
9 PC{3, 4, 7, 7.5}
10 PC{4, 5, 8, 8.5}
11 PC{5, 6, 9, 9.5}
Return type:

PitchClassSet

overridden union(*arguments)

Return the union of sets as a new set.

(i.e. all elements that are in either set.)


Read-only properties

cardinality
class abjad.pcollections.PitchRange(range_string='[A0, C8]')[source]

Pitch range.

Pitches from C3 to C7, inclusive:

>>> pitch_range = abjad.PitchRange("[C3, C7]")
>>> lilypond_file = abjad.illustrate(pitch_range)
>>> abjad.show(lilypond_file)  

Attributes Summary

__contains__

Is true when pitch range contains argument.

__eq__

Is true when argument is a pitch range with range_string equal to this pitch range.

__ge__

Return a >= b.

__gt__

Return a > b.

__hash__

Hashes pitch range.

__le__

Return a <= b.

__lt__

Is true when start pitch of this pitch-range is less than start pitch of argument pitch range.

__repr__

Gets pitch range interpreter representation.

from_octave

Initializes pitch range from octave.

range_string

Gets range string of pitch range.

start_pitch

Start pitch of pitch range.

stop_pitch

Stop pitch of pitch range.

voice_pitch_class

Voices pitch_class.


Special methods

__contains__(argument)[source]

Is true when pitch range contains argument.

Closed / closed range:

>>> range_ = abjad.PitchRange("[A0, C8]")
>>> "C0" in range_
False
>>> "A0" in range_
True
>>> "C4" in range_
True
>>> "C8" in range_
True
>>> "C12" in range_
False

Closed / open range:

>>> range_ = abjad.PitchRange("[A0, C8)")
>>> "C0" in range_
False
>>> "A0" in range_
True
>>> "C4" in range_
True
>>> "C8" in range_
False
>>> "C12" in range_
False

Closed / infinite range:

>>> range_ = abjad.PitchRange("[A0, +inf]")
>>> "C0" in range_
False
>>> "A0" in range_
True
>>> "C4" in range_
True
>>> "C8" in range_
True
>>> "C12" in range_
True

Open / closed range:

>>> range_ = abjad.PitchRange("(A0, C8]")
>>> "C0" in range_
False
>>> "A0" in range_
False
>>> "C4" in range_
True
>>> "C8" in range_
True
>>> "C12" in range_
False

Open / open range:

>>> range_ = abjad.PitchRange("(A0, C8)")
>>> "C0" in range_
False
>>> "A0" in range_
False
>>> "C4" in range_
True
>>> "C8" in range_
False
>>> "C12" in range_
False

Infinite / closed range:

>>> range_ = abjad.PitchRange("[-inf, C8]")
>>> "C0" in range_
True
>>> "A0" in range_
True
>>> "C4" in range_
True
>>> "C8" in range_
True
>>> "C12" in range_
False

Infinite / open range:

>>> range_ = abjad.PitchRange("[-inf, C8)")
>>> "C0" in range_
True
>>> "A0" in range_
True
>>> "C4" in range_
True
>>> "C8" in range_
False
>>> "C12" in range_
False

Infinite / infinite range:

>>> range_ = abjad.PitchRange("[-inf, +inf]")
>>> "C0" in range_
True
>>> "A0" in range_
True
>>> "C4" in range_
True
>>> "C8" in range_
True
>>> "C12" in range_
True

Raises exception when argument is not a named pitch or string:

>>> -99 in range_
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/trevor/abjad/abjad/pcollections.py", line 856, in __contains__
    raise Exception(f"must be named pitch or string (not {argument!r}).")
Exception: must be named pitch or string (not -99).
Return type:

bool

overridden __eq__(argument)[source]

Is true when argument is a pitch range with range_string equal to this pitch range.

>>> range_1 = abjad.PitchRange("[A0, C4]")
>>> range_2 = abjad.PitchRange("[A0, C4]")
>>> range_3 = abjad.PitchRange("[A0, C8]")
>>> range_1 == range_1
True
>>> range_1 == range_2
True
>>> range_1 == range_3
False
>>> range_2 == range_1
True
>>> range_2 == range_2
True
>>> range_2 == range_3
False
>>> range_3 == range_1
False
>>> range_3 == range_2
False
>>> range_3 == range_3
True
Return type:

bool

overridden __ge__(other)

Return a >= b. Computed by @total_ordering from (not a < b).

overridden __gt__(other)

Return a > b. Computed by @total_ordering from (not a < b) and (a != b).

overridden __hash__()[source]

Hashes pitch range.

Return type:

int

overridden __le__(other)

Return a <= b. Computed by @total_ordering from (a < b) or (a == b).

overridden __lt__(argument)[source]

Is true when start pitch of this pitch-range is less than start pitch of argument pitch range.

>>> range_1 = abjad.PitchRange("[A0, C4]")
>>> range_2 = abjad.PitchRange("[A0, C4]")
>>> range_3 = abjad.PitchRange("[A0, C8]")
>>> range_1 < range_1
False
>>> range_1 < range_2
False
>>> range_1 < range_3
True
>>> range_2 < range_1
False
>>> range_2 < range_2
False
>>> range_2 < range_3
True
>>> range_3 < range_1
False
>>> range_3 < range_2
False
>>> range_3 < range_3
False
Return type:

bool

overridden __repr__()[source]

Gets pitch range interpreter representation.

Return type:

str


Methods

voice_pitch_class(pitch_class)[source]

Voices pitch_class.

Voices C three times:

>>> pitch_range = abjad.PitchRange("[C4, C6]")
>>> pitch_range.voice_pitch_class("c")
(NamedPitch("c'"), NamedPitch("c''"), NamedPitch("c'''"))

Voices B two times:

>>> pitch_range = abjad.PitchRange("[C4, C6]")
>>> pitch_range.voice_pitch_class("b")
(NamedPitch("b'"), NamedPitch("b''"))

Returns empty because B can not voice:

>>> pitch_range = abjad.PitchRange("[C4, A4)")
>>> pitch_range.voice_pitch_class("b")
()

Class & static methods

static from_octave(octave)[source]

Initializes pitch range from octave.

>>> abjad.PitchRange.from_octave(5)
PitchRange(range_string='[C5, C6)')
Return type:

PitchRange


Read-only properties

range_string

Gets range string of pitch range.

>>> abjad.PitchRange("[C3, C7]").range_string
'[C3, C7]'
>>> abjad.PitchRange("[-inf, C7]").range_string
'[-inf, C7]'
>>> abjad.PitchRange("[C3, +inf]").range_string
'[C3, +inf]'
>>> abjad.PitchRange("[-inf, +inf]").range_string
'[-inf, +inf]'
start_pitch

Start pitch of pitch range.

>>> abjad.PitchRange("[C3, C7]").start_pitch
NamedPitch('c')
>>> abjad.PitchRange("[-inf, C7]").start_pitch is None
True
stop_pitch

Stop pitch of pitch range.

>>> abjad.PitchRange("[C3, C7]").stop_pitch
NamedPitch("c''''")
>>> abjad.PitchRange("[C8, +inf]").stop_pitch is None
True
class abjad.pcollections.PitchSegment(items=())[source]

Named pitch segment.

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> str(segment)
'<-2, -1.5, 6, 7, -1.5, 7>'
>>> lilypond_file = abjad.illustrate(segment)
>>> abjad.show(lilypond_file)  

Attributes Summary

__contains__

Is true when named pitch segment contains argument.

__eq__

Return self==value.

__getitem__

Gets item at argument in named pitch segment.

__iter__

Iterates named pitch segment.

__len__

Gets length of named pitch segment.

__post_init__

__repr__

Gets repr.

__str__

Gets string.

invert

Inverts named pitch segment about axis.

multiply

Multiplies pitch segment by index n.

retrograde

Retrograde of pitch segment.

rotate

Rotates pitch segment by index n.

transpose

Transposes pitch segment by index n.


Special methods

__contains__(argument)[source]

Is true when named pitch segment contains argument.

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> abjad.NamedPitch("fs'") in segment
False
>>> abjad.NamedPitch(6) in segment
False
>>> abjad.NamedPitch("fs") in segment
False
>>> 6 in segment
True
>>> abjad.NumberedPitch(6) in segment
True
>>> abjad.NumberedPitch("fs'") in segment
True
>>> abjad.NamedPitch("f") in segment
False
>>> 5 in segment
False
Return type:

bool

overridden __eq__(other)

Return self==value.

__getitem__(argument)[source]

Gets item at argument in named pitch segment.

__iter__()[source]

Iterates named pitch segment.

__len__()[source]

Gets length of named pitch segment.

__post_init__()[source]
overridden __repr__()[source]

Gets repr.

overridden __str__()[source]

Gets string.

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> str(segment)
'<-2, -1.5, 6, 7, -1.5, 7>'
Return type:

str


Methods

invert(axis=None)[source]

Inverts named pitch segment about axis.

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> lilypond_file = abjad.illustrate(segment)
>>> abjad.show(lilypond_file)  
>>> segment = segment.invert(axis=0)
>>> str(segment)
'<2, 1.5, -6, -7, 1.5, -7>'
>>> lilypond_file = abjad.illustrate(segment)
>>> abjad.show(lilypond_file)  
Return type:

PitchSegment

multiply(n=1)[source]

Multiplies pitch segment by index n.

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> lilypond_file = abjad.illustrate(segment)
>>> abjad.show(lilypond_file)  
>>> segment = segment.multiply(n=3)
>>> str(segment)
'<-6, -4.5, 18, 21, -4.5, 21>'
>>> lilypond_file = abjad.illustrate(segment)
>>> abjad.show(lilypond_file)  
Return type:

PitchSegment

retrograde()[source]

Retrograde of pitch segment.

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> lilypond_file = abjad.illustrate(segment)
>>> abjad.show(lilypond_file)  
>>> segment = segment.retrograde()
>>> str(segment)
'<7, -1.5, 7, 6, -1.5, -2>'
>>> lilypond_file = abjad.illustrate(segment)
>>> abjad.show(lilypond_file)  
Return type:

PitchSegment

rotate(n=0)[source]

Rotates pitch segment by index n.

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> lilypond_file = abjad.illustrate(segment)
>>> abjad.show(lilypond_file)  
>>> segment = segment.rotate(n=1)
>>> str(segment)
'<7, -2, -1.5, 6, 7, -1.5>'
>>> lilypond_file = abjad.illustrate(segment)
>>> abjad.show(lilypond_file)  
Return type:

PitchSegment

transpose(n=0)[source]

Transposes pitch segment by index n.

>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> lilypond_file = abjad.illustrate(segment)
>>> abjad.show(lilypond_file)  
>>> segment = segment.transpose(n=11)
>>> str(segment)
'<9, 9.5, 17, 18, 9.5, 18>'
>>> lilypond_file = abjad.illustrate(segment)
>>> abjad.show(lilypond_file)  
Return type:

PitchSegment

class abjad.pcollections.PitchSet(argument=())[source]

Numbered pitch set.

>>> set_1 = abjad.PitchSet([-26, -2.5, 6, 7, -1.5, 7])
>>> set_2 = abjad.PitchSet([-1.5, 7, 9, 12])
>>> set_1
PitchSet([-26, -2.5, -1.5, 6, 7])
>>> set_2
PitchSet([-1.5, 7, 9, 12])
>>> str(set_1)
'{-26, -2.5, -1.5, 6, 7}'
>>> str(set_2)
'{-1.5, 7, 9, 12}'
>>> -1.5 in set_1
False
>>> abjad.NumberedPitch(-1.5) in set_1
True
>>> abjad.NumberedPitch("aqs") in set_2
False
>>> len(set_1)
5
>>> len(set_2)
4

Classical operators:

>>> set_1 = abjad.PitchSet([-26, -2.5, 6, 7, -1.5, 7])
>>> set_2 = abjad.PitchSet([-1.5, 7, 9, 12])
>>> set_1 & set_2
PitchSet([-1.5, 7])
>>> set_2 & set_1
PitchSet([-1.5, 7])
>>> set_1.intersection(set_2)
PitchSet([-1.5, 7])
>>> set_2.intersection(set_1)
PitchSet([-1.5, 7])
>>> set_1 | set_2
PitchSet([-26, -2.5, -1.5, 6, 7, 9, 12])
>>> set_2 | set_1
PitchSet([-26, -2.5, -1.5, 6, 7, 9, 12])
>>> set_1.union(set_2)
PitchSet([-26, -2.5, -1.5, 6, 7, 9, 12])
>>> set_2.union(set_1)
PitchSet([-26, -2.5, -1.5, 6, 7, 9, 12])
>>> set_1 - set_2
PitchSet([-26, -2.5, 6])
>>> set_1.difference(set_2)
PitchSet([-26, -2.5, 6])
>>> set_2 - set_1
PitchSet([9, 12])
>>> set_2.difference(set_1)
PitchSet([9, 12])
>>> set_1 ^ set_2
PitchSet([-26, -2.5, 6, 9, 12])
>>> set_2 ^ set_1
PitchSet([-26, -2.5, 6, 9, 12])
>>> set_1.symmetric_difference(set_2)
PitchSet([-26, -2.5, 6, 9, 12])
>>> set_2.symmetric_difference(set_1)
PitchSet([-26, -2.5, 6, 9, 12])
>>> set_1 = abjad.PitchSet([-6, -5, -3, -1])
>>> set_2 = abjad.PitchSet([-3, -1])
>>> set_3 = abjad.PitchSet([1, 3, 4])

Predicates:

>>> set_1.isdisjoint(set_3)
True
>>> set_2.issubset(set_1)
True
>>> set_1.issuperset(set_2)
True
>>> set_1 = abjad.PitchSet([-26, -2.5, 6, 7, -1.5, 7])
>>> set_2 = abjad.PitchSet([-1.5, 7, 9, 12])

Comparison:

>>> set_1 == set_1
True
>>> set_1 == set_2
False
>>> set_1 < set_1
False
>>> set_1 < set_2
False
>>> set_1 <= set_1
True
>>> set_1 <= set_2
False
>>> set_1 > set_1
False
>>> set_1 > set_2
False
>>> set_1 >= set_1
True
>>> set_1 >= set_2
False

Copy:

>>> import copy
>>> set_1_copy = copy.copy(set_1)
>>> set_1_copy
PitchSet([-26, -2.5, -1.5, 6, 7])
>>> set_1 == set_1_copy
True

Empty set:

>>> set_ = abjad.PitchSet()
>>> set_
PitchSet()
>>> str(set_)
'{}'
>>> len(set_)
0
>>> bool(set_)
False

Attributes Summary

__and__

Return self&value.

__new__

__or__

Return self|value.

__repr__

Gets repr.

__str__

Gets string.

__sub__

Return self-value.

__xor__

Return self^value.

difference

Return the difference of two or more sets as a new set.

intersection

Return the intersection of two sets as a new set.

symmetric_difference

Return the symmetric difference of two sets as a new set.

union

Return the union of sets as a new set.


Special methods

overridden __and__(*arguments)

Return self&value.

(frozenset).__class_getitem__()

See PEP 585

(frozenset).__contains__()

x.__contains__(y) <==> y in x.

(frozenset).__eq__(value, /)

Return self==value.

(frozenset).__ge__(value, /)

Return self>=value.

(frozenset).__gt__(value, /)

Return self>value.

(frozenset).__hash__()

Return hash(self).

(frozenset).__iter__()

Implement iter(self).

(frozenset).__le__(value, /)

Return self<=value.

(frozenset).__len__()

Return len(self).

(frozenset).__lt__(value, /)

Return self<value.

(frozenset).__ne__(value, /)

Return self!=value.

overridden static __new__(class_, argument=())[source]
overridden __or__(*arguments)

Return self|value.

(frozenset).__rand__(value, /)

Return value&self.

overridden __repr__()[source]

Gets repr.

(frozenset).__ror__(value, /)

Return value|self.

(frozenset).__rsub__(value, /)

Return value-self.

(frozenset).__rxor__(value, /)

Return value^self.

overridden __str__()[source]

Gets string.

Return type:

str

overridden __sub__(*arguments)

Return self-value.

overridden __xor__(*arguments)

Return self^value.


Methods

(frozenset).copy()

Return a shallow copy of a set.

overridden difference(*arguments)

Return the difference of two or more sets as a new set.

(i.e. all elements that are in this set but not the others.)

overridden intersection(*arguments)

Return the intersection of two sets as a new set.

(i.e. all elements that are in both sets.)

(frozenset).isdisjoint()

Return True if two sets have a null intersection.

(frozenset).issubset()

Report whether another set contains this set.

(frozenset).issuperset()

Report whether this set contains another set.

overridden symmetric_difference(*arguments)

Return the symmetric difference of two sets as a new set.

(i.e. all elements that are in exactly one of the sets.)

overridden union(*arguments)

Return the union of sets as a new set.

(i.e. all elements that are in either set.)

class abjad.pcollections.TwelveToneRow(items=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11))[source]

Twelve-tone row.

Initializes from defaults:

>>> row = abjad.TwelveToneRow()
>>> lilypond_file = abjad.illustrate(row)
>>> abjad.show(lilypond_file)  

Initializes from integers:

>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0]
>>> row = abjad.TwelveToneRow(numbers)
>>> lilypond_file = abjad.illustrate(row)
>>> abjad.show(lilypond_file)  

Interpreter representation:

>>> row
TwelveToneRow(items=(NumberedPitchClass(1), NumberedPitchClass(11), NumberedPitchClass(9), NumberedPitchClass(3), NumberedPitchClass(6), NumberedPitchClass(7), NumberedPitchClass(5), NumberedPitchClass(4), NumberedPitchClass(10), NumberedPitchClass(2), NumberedPitchClass(8), NumberedPitchClass(0)))

Attributes Summary

__call__

Calls row on pitch_classes.

__eq__

Return self==value.

__getitem__

Gets item or slice identified by argument.

__mul__

Multiplies row by argument.

__post_init__

__repr__

Gets repr.

__rmul__

Multiplies argument by row.

invert

Inverts row about optional axis.

multiply

Multiplies pitch-classes in row by n.

retrograde

Gets retrograde of row.

rotate

Rotates row by index n.

transpose

Transposes row by index n.


Special methods

(PitchClassSegment).__add__(argument)

Adds argument to numbered pitch-class segment.

Return type:

PitchClassSegment

overridden __call__(pitch_classes)[source]

Calls row on pitch_classes.

Example row:

>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0]
>>> row = abjad.TwelveToneRow(numbers)
>>> lilypond_file = abjad.illustrate(row)
>>> abjad.show(lilypond_file)  

Permutes pitch-classes:

>>> row([abjad.NumberedPitchClass(2)])
[NumberedPitchClass(9)]
>>> row([abjad.NumberedPitchClass(3)])
[NumberedPitchClass(3)]
>>> row([abjad.NumberedPitchClass(4)])
[NumberedPitchClass(6)]

Permutes pitch-class segment:

>>> segment = abjad.PitchClassSegment([-2, -1, 6, 7, -1, 7])
>>> lilypond_file = abjad.illustrate(segment)
>>> abjad.show(lilypond_file)  
>>> voice = lilypond_file["Voice"]
>>> string = abjad.lilypond(voice)
>>> print(string)
\context Voice = "Voice"
{
    bf'8
    b'8
    fs'8
    g'8
    b'8
    g'8
    \bar "|."
    \override Score.BarLine.transparent = ##f
}
>>> row_ = abjad.TwelveToneRow([10, 0, 2, 6, 8, 7, 5, 3, 1, 9, 4, 11])
>>> segment = row_(segment)
>>> segment
PitchClassSegment([4, 11, 5, 3, 11, 3])
>>> lilypond_file = abjad.illustrate(segment)
>>> abjad.show(lilypond_file)  

Permutes row:

>>> numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
>>> row_2 = abjad.TwelveToneRow(numbers)
>>> lilypond_file = abjad.illustrate(row_2)
>>> abjad.show(lilypond_file)  
>>> row_3 = row(row_2)
>>> lilypond_file = abjad.illustrate(row_3)
>>> abjad.show(lilypond_file)  

Permutes row:

>>> numbers = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
>>> row_2 = abjad.TwelveToneRow(numbers)
>>> lilypond_file = abjad.illustrate(row_2)
>>> abjad.show(lilypond_file)  
>>> row_3 = row(row_2)
>>> lilypond_file = abjad.illustrate(row_3)
>>> abjad.show(lilypond_file)  

Permutes row:

>>> numbers = [10, 0, 2, 6, 8, 7, 5, 3, 1, 9, 4, 11]
>>> row_2 = abjad.TwelveToneRow(numbers)
>>> lilypond_file = abjad.illustrate(row_2)
>>> abjad.show(lilypond_file)  
>>> row_3 = row(row_2)
>>> lilypond_file = abjad.illustrate(row_3)
>>> abjad.show(lilypond_file)  

Returns permuted pitch-classes in object of type pitch_classes.

(PitchClassSegment).__contains__(argument)

Is true when numbered pitch-class segment contains argument.

Return type:

bool

overridden __eq__(other)

Return self==value.

overridden __getitem__(argument)[source]

Gets item or slice identified by argument.

Example row:

>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0]
>>> row = abjad.TwelveToneRow(numbers)
>>> lilypond_file = abjad.illustrate(row)
>>> abjad.show(lilypond_file)  

Gets first hexachord:

>>> lilypond_file = abjad.illustrate(row[:6])
>>> abjad.show(lilypond_file)  

Gets second hexachord:

>>> lilypond_file = abjad.illustrate(row[-6:])
>>> abjad.show(lilypond_file)  

Gets items in row:

>>> row = abjad.TwelveToneRow()
>>> lilypond_file = abjad.illustrate(row)
>>> abjad.show(lilypond_file)  
>>> for item in row.items:
...     item
... 
NumberedPitchClass(0)
NumberedPitchClass(1)
NumberedPitchClass(2)
NumberedPitchClass(3)
NumberedPitchClass(4)
NumberedPitchClass(5)
NumberedPitchClass(6)
NumberedPitchClass(7)
NumberedPitchClass(8)
NumberedPitchClass(9)
NumberedPitchClass(10)
NumberedPitchClass(11)

Gets items in row:

>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0]
>>> row = abjad.TwelveToneRow(numbers)
>>> lilypond_file = abjad.illustrate(row)
>>> abjad.show(lilypond_file)  
>>> for item in row.items:
...     item
... 
NumberedPitchClass(1)
NumberedPitchClass(11)
NumberedPitchClass(9)
NumberedPitchClass(3)
NumberedPitchClass(6)
NumberedPitchClass(7)
NumberedPitchClass(5)
NumberedPitchClass(4)
NumberedPitchClass(10)
NumberedPitchClass(2)
NumberedPitchClass(8)
NumberedPitchClass(0)
(PitchClassSegment).__iter__()

Iterates numbered pitch-class segment.

(PitchClassSegment).__len__()

Gets length of numbered pitch-class segment.

overridden __mul__(argument)[source]

Multiplies row by argument.

Multiplies row:

>>> row = abjad.TwelveToneRow()
>>> lilypond_file = abjad.illustrate(row)
>>> abjad.show(lilypond_file)  
>>> segment = 2 * row
>>> lilypond_file = abjad.illustrate(segment)
>>> abjad.show(lilypond_file)  

Multiplies row:

>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0]
>>> row = abjad.TwelveToneRow(numbers)
>>> lilypond_file = abjad.illustrate(segment)
>>> abjad.show(lilypond_file)  
>>> segment = 2 * row
>>> lilypond_file = abjad.illustrate(segment)
>>> abjad.show(lilypond_file)  
Return type:

PitchClassSegment

overridden __post_init__()[source]
overridden __repr__()

Gets repr.

overridden __rmul__(argument)[source]

Multiplies argument by row.

Multiplies integer by row:

>>> row = abjad.TwelveToneRow()
>>> lilypond_file = abjad.illustrate(row)
>>> abjad.show(lilypond_file)  
>>> segment = row * 2
>>> lilypond_file = abjad.illustrate(segment)
>>> abjad.show(lilypond_file)  

Multiplies integer by row:

>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0]
>>> row = abjad.TwelveToneRow(numbers)
>>> lilypond_file = abjad.illustrate(row)
>>> abjad.show(lilypond_file)  
>>> segment = row * 2
>>> lilypond_file = abjad.illustrate(segment)
>>> abjad.show(lilypond_file)  
Return type:

PitchClassSegment

(PitchClassSegment).__str__()

Gets string representation of numbered pitch-class segment.

>>> segment = abjad.PitchClassSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> str(segment)
'PC<10, 10.5, 6, 7, 10.5, 7>'
Return type:

str


Methods

overridden invert(axis=None)[source]

Inverts row about optional axis.

Example row:

>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0]
>>> row = abjad.TwelveToneRow(numbers)
>>> lilypond_file = abjad.illustrate(row)
>>> abjad.show(lilypond_file)  

Inverts row about first pitch-class when axis is none:

>>> inversion = row.invert()
>>> lilypond_file = abjad.illustrate(inversion)
>>> abjad.show(lilypond_file)  

First pitch-classes are equal:

>>> row[0] == inversion[0]
True

Inverts row about pitch-class 1:

>>> inversion = row.invert(axis=1)
>>> lilypond_file = abjad.illustrate(inversion)
>>> abjad.show(lilypond_file)  

Same result as above.

Inverts row about pitch-class 0:

>>> inversion = row.invert(axis=0)
>>> lilypond_file = abjad.illustrate(inversion)
>>> abjad.show(lilypond_file)  

Inverts row about pitch-class 5:

>>> inversion = row.invert(axis=5)
>>> lilypond_file = abjad.illustrate(inversion)
>>> abjad.show(lilypond_file)  
Return type:

TwelveToneRow

overridden multiply(n=1)[source]

Multiplies pitch-classes in row by n.

Example row:

>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0]
>>> row = abjad.TwelveToneRow(numbers)
>>> lilypond_file = abjad.illustrate(row)
>>> abjad.show(lilypond_file)  

Multiplies pitch-classes in row by 5:

>>> multiplication = row.multiply(n=5)
>>> lilypond_file = abjad.illustrate(multiplication)
>>> abjad.show(lilypond_file)  

Multiplies pitch-classes in row by 7:

>>> multiplication = row.multiply(n=7)
>>> lilypond_file = abjad.illustrate(multiplication)
>>> abjad.show(lilypond_file)  

Multiplies pitch-classes in row by 1:

>>> multiplication = row.multiply(n=1)
>>> lilypond_file = abjad.illustrate(multiplication)
>>> abjad.show(lilypond_file)  
Return type:

TwelveToneRow

overridden retrograde()[source]

Gets retrograde of row.

Example row:

>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0]
>>> row = abjad.TwelveToneRow(numbers)
>>> lilypond_file = abjad.illustrate(row)
>>> abjad.show(lilypond_file)  

Gets retrograde of row:

>>> retrograde = row.retrograde()
>>> lilypond_file = abjad.illustrate(retrograde)
>>> abjad.show(lilypond_file)  

Gets retrograde of retrograde of row:

>>> retrograde = row.retrograde().retrograde()
>>> lilypond_file = abjad.illustrate(retrograde)
>>> abjad.show(lilypond_file)  
>>> retrograde == row
True
Return type:

TwelveToneRow

overridden rotate(n=0)[source]

Rotates row by index n.

Example row:

>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0]
>>> row = abjad.TwelveToneRow(numbers)
>>> lilypond_file = abjad.illustrate(row)
>>> abjad.show(lilypond_file)  

Rotates row to the right:

>>> rotation = row.rotate(n=1)
>>> lilypond_file = abjad.illustrate(rotation)
>>> abjad.show(lilypond_file)  

Rotates row to the left:

>>> rotation = row.rotate(n=-1)
>>> lilypond_file = abjad.illustrate(rotation)
>>> abjad.show(lilypond_file)  

Rotates row by zero:

>>> rotation = row.rotate(n=0)
>>> lilypond_file = abjad.illustrate(rotation)
>>> abjad.show(lilypond_file)  
>>> rotation == row
True
Return type:

TwelveToneRow

overridden transpose(n=0)[source]

Transposes row by index n.

Example row:

>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0]
>>> row = abjad.TwelveToneRow(numbers)
>>> lilypond_file = abjad.illustrate(row)
>>> abjad.show(lilypond_file)  

Transposes row by positive index:

>>> transposition = row.transpose(n=13)
>>> lilypond_file = abjad.illustrate(transposition)
>>> abjad.show(lilypond_file)  

Transposes row by negative index:

>>> transposition = row.transpose(n=-13)
>>> lilypond_file = abjad.illustrate(transposition)
>>> abjad.show(lilypond_file)  

Transposes row by zero index:

>>> transposition = row.transpose(n=0)
>>> lilypond_file = abjad.illustrate(transposition)
>>> abjad.show(lilypond_file)  
>>> transposition == row
True
Return type:

TwelveToneRow


Functions

make_interval_class_vector

Makes interval-class vector.

voice_horizontally

Voices named pcs with each pitch as close to the previous pitch as possible.

voice_vertically

Voices named pcs with each pitch not lower than the previous.

abjad.pcollections.make_interval_class_vector(pitches)[source]

Makes interval-class vector.

abjad.pcollections.voice_horizontally(pcs, initial_octave=Octave(number=4))[source]

Voices named pcs with each pitch as close to the previous pitch as possible.

>>> pcs = [abjad.NamedPitchClass(_) for _ in "c b d e f g e b a c".split()]
>>> pitches = abjad.pcollections.voice_horizontally(pcs)
>>> staff = abjad.Staff([abjad.Note(_, (1, 8)) for _ in pitches])
>>> abjad.show(staff)  
Return type:

tuple[NamedPitch, ...]

abjad.pcollections.voice_vertically(pcs, initial_octave=Octave(number=4))[source]

Voices named pcs with each pitch not lower than the previous.

>>> pcs = [abjad.NamedPitchClass(_) for _ in "c ef g bf d f af".split()]
>>> pitches = abjad.pcollections.voice_vertically(pcs)
>>> staff = abjad.Staff([abjad.Note(_, (1, 8)) for _ in pitches])
>>> abjad.show(staff)  
Return type:

tuple[NamedPitch, ...]