PitchSet

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

Pitch set.

>>> numbered_pitch_set = pitchtools.PitchSet(
...     items=[-2, -1.5, 6, 7, -1.5, 7],
...     item_class=pitchtools.NumberedPitch,
...     )
>>> numbered_pitch_set
PitchSet([-2, -1.5, 6, 7])
>>> print(format(numbered_pitch_set))
pitchtools.PitchSet(
    [-2, -1.5, 6, 7]
    )
>>> named_pitch_set = pitchtools.PitchSet(
...     ['bf,', 'aqs', "fs'", "g'", 'bqf', "g'"],
...     item_class=NamedPitch,
...     )
>>> named_pitch_set
PitchSet(['bf,', 'aqs', 'bqf', "fs'", "g'"])
>>> print(format(named_pitch_set))
pitchtools.PitchSet(
    ['bf,', 'aqs', 'bqf', "fs'", "g'"]
    )

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.TypedFrozenset.TypedFrozenset" [color=3, group=2, label=TypedFrozenset, shape=box]; "abjad.tools.datastructuretools.TypedCollection.TypedCollection" -> "abjad.tools.datastructuretools.TypedFrozenset.TypedFrozenset"; } subgraph cluster_pitchtools { graph [label=pitchtools]; "abjad.tools.pitchtools.PitchSet.PitchSet" [color=black, fontcolor=white, group=3, label=<<B>PitchSet</B>>, shape=box, style="filled, rounded"]; "abjad.tools.pitchtools.Set.Set" [color=4, group=3, label=Set, shape=oval, style=bold]; "abjad.tools.pitchtools.Set.Set" -> "abjad.tools.pitchtools.PitchSet.PitchSet"; } 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.TypedFrozenset.TypedFrozenset" -> "abjad.tools.pitchtools.Set.Set"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Attribute summary

copy() Copies typed frozen set.
difference(expr) Typed frozen set set-minus expr.
duplicate_pitch_classes Duplicate pitch-classes in pitch set.
from_selection(class_, selection[, item_class]) Makes pitch set from selection.
hertz Gets hertz of pitches in pitch segment.
intersection(expr) Set-theoretic intersection of typed frozen set and expr.
invert(axis) Inverts pitch set about axis.
is_equivalent_under_transposition(expr) True if pitch set is equivalent to expr under transposition.
is_pitch_class_unique Is true when pitch set is pitch-class-unique.
isdisjoint(expr) Is true when typed frozen set shares no elements with expr.
issubset(expr) Is true when typed frozen set is a subset of expr.
issuperset(expr) Is true when typed frozen set is a superset of expr.
item_class Item class to coerce items into.
items Gets collection items.
register(pitch_classes) Registers pitch_classes by pitch set.
symmetric_difference(expr) Symmetric difference of typed frozen set and expr.
transpose(expr) Transposes all pitches in pitch set by expr.
union(expr) Union of typed frozen set and expr.
__and__(expr) Logical AND of typed frozen set and expr.
__contains__(item) Is true when typed collection container item.
__eq__(expr) Is true when expr is a typed collection with items that compare equal to those of this typed collection.
__format__([format_specification]) Formats Abjad object.
__ge__(expr) Is true when typed frozen set is greater than or equal to expr.
__gt__(expr) Is true when typed frozen set is greater than expr.
__hash__() Hashes typed frozen set.
__iter__() Iterates typed collection.
__le__(expr) Is true when typed frozen set is less than or equal to expr.
__len__() Length of typed collection.
__lt__(expr) Is true when typed frozen set is less than expr.
__ne__(expr) Is true when typed frozen set is not equal to expr.
__or__(expr) Logical OR of typed frozen set and expr.
__repr__() Gets interpreter representation of Abjad object.
__str__() String representation of set.
__sub__(expr) Subtracts expr from typed frozen set.
__xor__(expr) Logical XOR of typed frozen set and expr.

Read-only properties

PitchSet.duplicate_pitch_classes

Duplicate pitch-classes in pitch set.

Returns pitch-class set.

PitchSet.hertz

Gets hertz of pitches in pitch segment.

>>> pitch_set = pitchtools.PitchSet('c e g b')
>>> sorted(pitch_set.hertz)
[130.81..., 164.81..., 195.99..., 246.94...]

Returns set.

PitchSet.is_pitch_class_unique

Is true when pitch set is pitch-class-unique. Otherwise false.

Returns true or false.

(TypedCollection).item_class

Item class to coerce items into.

(TypedCollection).items

Gets collection items.

Methods

(TypedFrozenset).copy()

Copies typed frozen set.

Returns new typed frozen set.

(TypedFrozenset).difference(expr)

Typed frozen set set-minus expr.

Returns new typed frozen set.

(TypedFrozenset).intersection(expr)

Set-theoretic intersection of typed frozen set and expr.

Returns new typed frozen set.

PitchSet.invert(axis)

Inverts pitch set about axis.

Returns new pitch set.

PitchSet.is_equivalent_under_transposition(expr)

True if pitch set is equivalent to expr under transposition. Otherwise false.

Returns true or false.

(TypedFrozenset).isdisjoint(expr)

Is true when typed frozen set shares no elements with expr. Otherwise false.

Returns true or false.

(TypedFrozenset).issubset(expr)

Is true when typed frozen set is a subset of expr. Otherwise false.

Returns true or false.

(TypedFrozenset).issuperset(expr)

Is true when typed frozen set is a superset of expr. Otherwise false.

Returns true or false.

PitchSet.register(pitch_classes)

Registers pitch_classes by pitch set.

>>> pitch_set = pitchtools.PitchSet(
...     items=[10, 19, 20, 23, 24, 26, 27, 29, 30, 33, 37, 40],
...     item_class=pitchtools.NumberedPitch,
...     )
>>> pitch_classes = [10, 0, 2, 6, 8, 7, 5, 3, 1, 9, 4, 11]
>>> pitches = pitch_set.register(pitch_classes)
>>> for pitch in pitches:
...     pitch
NumberedPitch(10)
NumberedPitch(24)
NumberedPitch(26)
NumberedPitch(30)
NumberedPitch(20)
NumberedPitch(19)
NumberedPitch(29)
NumberedPitch(27)
NumberedPitch(37)
NumberedPitch(33)
NumberedPitch(40)
NumberedPitch(23)

Returns list of zero or more numbered pitches.

(TypedFrozenset).symmetric_difference(expr)

Symmetric difference of typed frozen set and expr.

Returns new typed frozen set.

PitchSet.transpose(expr)

Transposes all pitches in pitch set by expr.

Returns new pitch set.

(TypedFrozenset).union(expr)

Union of typed frozen set and expr.

Returns new typed frozen set.

Class & static methods

classmethod PitchSet.from_selection(class_, selection, item_class=None)

Makes pitch set from selection.

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

Returns pitch set.

Special methods

(TypedFrozenset).__and__(expr)

Logical AND of typed frozen set and expr.

Returns new typed frozen set.

(TypedCollection).__contains__(item)

Is true when typed collection container item. Otherwise false.

Returns true or false.

(TypedCollection).__eq__(expr)

Is true when expr 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.

(TypedFrozenset).__ge__(expr)

Is true when typed frozen set is greater than or equal to expr. Otherwise false.

Returns true or false.

(TypedFrozenset).__gt__(expr)

Is true when typed frozen set is greater than expr. Otherwise false.

Returns true or false.

(TypedFrozenset).__hash__()

Hashes typed frozen set.

Returns integer.

(TypedCollection).__iter__()

Iterates typed collection.

Returns generator.

(TypedFrozenset).__le__(expr)

Is true when typed frozen set is less than or equal to expr. Otherwise false.

Returns true or false.

(TypedCollection).__len__()

Length of typed collection.

Returns nonnegative integer.

(TypedFrozenset).__lt__(expr)

Is true when typed frozen set is less than expr. Otherwise false.

Returns true or false.

(TypedFrozenset).__ne__(expr)

Is true when typed frozen set is not equal to expr. Otherwise false.

Returns true or false.

(TypedFrozenset).__or__(expr)

Logical OR of typed frozen set and expr.

Returns new typed frozen set.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

(Set).__str__()

String representation of set.

Returns string.

(TypedFrozenset).__sub__(expr)

Subtracts expr from typed frozen set.

Returns new typed frozen set.

(TypedFrozenset).__xor__(expr)

Logical XOR of typed frozen set and expr.

Returns new typed frozen set.