PitchClassSet

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.PitchClassSet.PitchClassSet" [URL="../api/abjad/pitch/PitchClassSet.html#abjad.pitch.PitchClassSet.PitchClassSet", color=black, fontcolor=white, label="Pitch\nClass\nSet", target=_top]; "abjad.pitch.Set.Set" [URL="../api/abjad/pitch/Set.html#abjad.pitch.Set.Set", label=Set, shape=oval, style=bold, target=_top]; "abjad.pitch.Set.Set" -> "abjad.pitch.PitchClassSet.PitchClassSet"; } 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.TypedFrozenset.TypedFrozenset" [URL="../api/abjad/pitch/../utilities/TypedFrozenset.html#abjad.utilities.TypedFrozenset.TypedFrozenset", label="Typed\nFrozenset", target=_top]; "abjad.utilities.TypedCollection.TypedCollection" -> "abjad.utilities.TypedFrozenset.TypedFrozenset"; } 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.Set" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Set", label=Set, 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.Set"; "collections.abc.Container" -> "collections.abc.Collection"; "collections.abc.Iterable" -> "collections.abc.Collection"; "collections.abc.Sized" -> "collections.abc.Collection"; } "abjad.system.AbjadObject.AbjadObject" -> "abjad.utilities.TypedCollection.TypedCollection"; "abjad.utilities.TypedFrozenset.TypedFrozenset" -> "abjad.pitch.Set.Set"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; "builtins.object" -> "collections.abc.Container"; "builtins.object" -> "collections.abc.Iterable"; "builtins.object" -> "collections.abc.Sized"; "collections.abc.Set" -> "abjad.utilities.TypedFrozenset.TypedFrozenset"; }

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

Pitch-class set.

Initializes numbered pitch-class set:

>>> numbered_pitch_class_set = abjad.PitchClassSet(
...     items=[-2, -1.5, 6, 7, -1.5, 7],
...     item_class=abjad.NumberedPitchClass,
...     )
>>> numbered_pitch_class_set
PitchClassSet([6, 7, 10, 10.5])

Initializes named pitch-class set:

>>> named_pitch_class_set = abjad.PitchClassSet(
...     items=['c', 'ef', 'bqs,', 'd'],
...     item_class=abjad.NamedPitchClass,
...     )
>>> named_pitch_class_set
PitchClassSet(['c', 'd', 'ef', 'bqs'])

Attributes Summary

__contains__ Is true when pitch-class set contains argument.
__hash__ Hashes pitch-class set.
__illustrate__ Illustrates pitch-class set.
__str__ Gets string representation of pitch-class set.
from_selection Makes pitch-class set from selection.
get_normal_order Gets normal order.
get_prime_form Gets prime form.
invert Inverts pitch-class set.
is_transposed_subset Is true when pitch-class set is transposed subset of pcset.
is_transposed_superset Is true when pitch-class set is transposed superset of pcset.
multiply Multiplies pitch-class set by n.
order_by Orders pitch-class set by pitch-class segment.
transpose Transposes all pitch-classes in pitch-class set by index n.

Special methods

(TypedFrozenset).__and__(argument)

Logical AND of typed frozen set and argument.

Returns new typed frozen set.

__contains__(argument)

Is true when pitch-class set contains argument.

Initializes numbered pitch-class set:

>>> set_ = abjad.PitchClassSet(
...     items=[-2, -1.5, 6, 7, -1.5, 7],
...     item_class=abjad.NumberedPitchClass,
...     )
>>> set_
PitchClassSet([6, 7, 10, 10.5])
>>> abjad.NamedPitch('fs') in set_
True
>>> abjad.NamedPitch('f') in set_
False
>>> 6 in set_
True
>>> 5 in set_
False

Returns true or false.

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

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to '' or 'storage'. Interprets '' equal to 'storage'.

Returns string.

(TypedFrozenset).__ge__(argument)

Is true when typed frozen set is greater than or equal to argument.

Returns true or false.

(TypedFrozenset).__gt__(argument)

Is true when typed frozen set is greater than argument.

Returns true or false.

__hash__()

Hashes pitch-class set.

Returns integer.

__illustrate__()

Illustrates pitch-class set.

Illustrates numbered segment:

>>> setting = abjad.PitchClassSet([-2, -1.5, 6, 7, -1.5, 7])
>>> abjad.show(setting) 

Illustrates named set:

>>> items = ['c', 'ef', 'bqs,', 'd']
>>> setting = abjad.PitchClassSet(
...     items=items,
...     item_class=abjad.NamedPitchClass,
...     )
>>> abjad.show(setting) 

Returns LilyPond file:

>>> prototype = abjad.LilyPondFile
>>> isinstance(setting.__illustrate__(), prototype)
True
(TypedCollection).__iter__()

Iterates typed collection.

Returns generator.

(TypedFrozenset).__le__(argument)

Is true when typed frozen set is less than or equal to argument.

Returns true or false.

(TypedCollection).__len__()

Gets length of typed collection.

Returns nonnegative integer.

(TypedFrozenset).__lt__(argument)

Is true when typed frozen set is less than argument.

Returns true or false.

(TypedFrozenset).__or__(argument)

Logical OR of typed frozen set and argument.

Returns new typed frozen set.

(Set).__rand__(other)
(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

(Set).__ror__(other)
(Set).__rsub__(other)
(Set).__rxor__(other)
__str__()

Gets string representation of pitch-class set.

Gets string of set sorted at initialization:

>>> pc_set = abjad.PitchClassSet([6, 7, 10, 10.5])
>>> str(pc_set)
'PC{6, 7, 10, 10.5}'

Gets string of set not sorted at initialization:

>>> pc_set = abjad.PitchClassSet([10.5, 10, 7, 6])
>>> str(pc_set)
'PC{6, 7, 10, 10.5}'

Returns string.

(TypedFrozenset).__sub__(argument)

Subtracts argument from typed frozen set.

Returns new typed frozen set.

(TypedFrozenset).__xor__(argument)

Logical XOR of typed frozen set and argument.

Returns new typed frozen set.


Methods

(TypedFrozenset).copy()

Copies typed frozen set.

Returns new typed frozen set.

(TypedFrozenset).difference(argument)

Typed frozen set set-minus argument.

Returns new typed frozen set.

get_normal_order()

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])

Returns pitch-class segment.

get_prime_form(transposition_only=False)

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.

(TypedFrozenset).intersection(argument)

Set-theoretic intersection of typed frozen set and argument.

Returns new typed frozen set.

invert(axis=None)

Inverts pitch-class set.

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

Returns numbered pitch-class set.

is_transposed_subset(pcset)

Is true when pitch-class set is transposed subset of pcset.

>>> pitch_class_set_1 = abjad.PitchClassSet(
...     [-2, -1.5, 6, 7, -1.5, 7],
...     )
>>> pitch_class_set_2 = abjad.PitchClassSet(
...     [-2, -1.5, 6, 7, -1.5, 7, 7.5, 8],
...     )
>>> pitch_class_set_1.is_transposed_subset(pitch_class_set_2)
True

Returns true or false.

is_transposed_superset(pcset)

Is true when pitch-class set is transposed superset of pcset.

>>> pitch_class_set_1 = abjad.PitchClassSet(
...     [-2, -1.5, 6, 7, -1.5, 7],
...     )
>>> pitch_class_set_2 = abjad.PitchClassSet(
...     [-2, -1.5, 6, 7, -1.5, 7, 7.5, 8],
...     )
>>> pitch_class_set_2.is_transposed_superset(pitch_class_set_1)
True

Returns true or false.

(TypedFrozenset).isdisjoint(argument)

Is true when typed frozen set shares no elements with argument.

Returns true or false.

(TypedFrozenset).issubset(argument)

Is true when typed frozen set is a subset of argument.

Returns true or false.

(TypedFrozenset).issuperset(argument)

Is true when typed frozen set is a superset of argument.

Returns true or false.

multiply(n)

Multiplies pitch-class set by n.

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

Returns new pitch-class set.

order_by(segment)

Orders pitch-class set by pitch-class segment.

>>> set_ = abjad.PitchClassSet(['c', 'e', 'b'])
>>> segment = abjad.PitchClassSegment(['e', 'a', 'f'])
>>> set_.order_by(segment)
PitchClassSegment("b e c")

Returns pitch-class segment.

(TypedFrozenset).symmetric_difference(argument)

Symmetric difference of typed frozen set and argument.

Returns new typed frozen set.

transpose(n=0)

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

>>> set_ = abjad.PitchClassSet(
...     items=[-2, -1.5, 6, 7, -1.5, 7],
...     item_class=abjad.NumberedPitchClass,
...     )
>>> 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}

Returns new pitch-class set.

(TypedFrozenset).union(argument)

Union of typed frozen set and argument.

Returns new typed frozen set.


Class & static methods

classmethod from_selection(selection, item_class=None)

Makes pitch-class set from selection.

>>> staff_1 = abjad.Staff("c'4 <d' fs' a'>4 b2")
>>> staff_2 = abjad.Staff("c4. r8 g2")
>>> selection = abjad.select((staff_1, staff_2))
>>> abjad.PitchClassSet.from_selection(selection)
PitchClassSet(['c', 'd', 'fs', 'g', 'a', 'b'])

Returns pitch-class set.


Read-only properties

(Set).cardinality

Gets cardinality of set.

Defined equal to length of set.

Returns nonnegative integer.

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