CompoundOperator

class pitchtools.CompoundOperator(operators=None, show_identity_operators=None)

Compound operator.

Rotation followed by transposition:

>>> operator = pitchtools.CompoundOperator()
>>> operator = operator.rotate(n=1, stravinsky=True)
>>> operator = operator.transpose(n=2)
>>> str(operator)
'T2rs1'
>>> pitch_classes = pitchtools.PitchClassSegment([0, 1, 4, 7])
>>> operator(pitch_classes)
PitchClassSegment([2, 7, 8, 11])

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.AbjadValueObject.AbjadValueObject" [color=1, group=0, label=AbjadValueObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.abctools.AbjadValueObject.AbjadValueObject"; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_pitchtools { graph [label=pitchtools]; "abjad.tools.pitchtools.CompoundOperator.CompoundOperator" [color=black, fontcolor=white, group=2, label=<<B>CompoundOperator</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadValueObject.AbjadValueObject" -> "abjad.tools.pitchtools.CompoundOperator.CompoundOperator"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

duplicate([counts, indices, period]) Configures compound operator to duplicate pitches by counts, with optional indices and period.
invert([axis]) Configures compound operator to invert pitches about axis.
multiply([n]) Configures compound operator to multiply pitch-classes by index n.
operators Gets operators.
retrograde([period]) Configures compound operator to retrograde pitches.
rotate([n, period, stravinsky]) Configures compound operator to rotate pitches by index n.
show_identity_operators Is true when string representation of operator should show identity operators.
transpose([n]) Configures compound operator to transpose pitches by index n.
__add__(operator) Composes compound operator and operator.
__call__(argument) Calls compound operator on argument.
__copy__(*arguments) Copies Abjad value object.
__eq__(argument) Is true when all initialization values of Abjad value object equal the initialization values of argument.
__format__([format_specification]) Formats Abjad object.
__hash__() Hashes Abjad value object.
__ne__(argument) Is true when Abjad object does not equal argument.
__radd__(operator) Composes operator and compound operator.
__repr__() Gets interpreter representation of Abjad object.
__str__() Gets string representation of compound operator.

Read-only properties

CompoundOperator.operators

Gets operators.

Gets operators:

>>> operator = pitchtools.CompoundOperator()
>>> operator = operator.rotate(n=1)
>>> operator = operator.transpose(n=2)
>>> for operator_ in operator.operators:
...     operator_
...
Rotation(n=1)
Transposition(n=2)

Returns list of operators.

CompoundOperator.show_identity_operators

Is true when string representation of operator should show identity operators. Otherwise false.

Does not show identity operators:

>>> operator = pitchtools.CompoundOperator()
>>> operator = operator.transpose(n=0)
>>> operator = operator.multiply(n=5)
>>> str(operator)
'M5'

Shows identity operators:

>>> operator = pitchtools.CompoundOperator(
...     show_identity_operators=True,
...     )
>>> operator = operator.transpose(n=0)
>>> operator = operator.multiply(n=5)
>>> str(operator)
'M5T0'

Defaults to none.

Set to true, false or none.

Returns true, false or none.

Methods

CompoundOperator.duplicate(counts=None, indices=None, period=None)

Configures compound operator to duplicate pitches by counts, with optional indices and period.

>>> operator = pitchtools.CompoundOperator()
>>> operator = operator.duplicate(counts=1)
>>> f(operator)
pitchtools.CompoundOperator(
    operators=[
        sequencetools.Duplication(
            counts=1,
            ),
        ],
    )

Returns new compound operator.

CompoundOperator.invert(axis=None)

Configures compound operator to invert pitches about axis.

>>> operator = pitchtools.CompoundOperator()
>>> operator = operator.invert(axis=2)
>>> f(operator)
pitchtools.CompoundOperator(
    operators=[
        pitchtools.Inversion(
            axis=pitchtools.NamedPitch("d'"),
            ),
        ],
    )

Returns new compound operator.

CompoundOperator.multiply(n=1)

Configures compound operator to multiply pitch-classes by index n.

>>> operator = pitchtools.CompoundOperator()
>>> operator = operator.multiply(n=3)
>>> f(operator)
pitchtools.CompoundOperator(
    operators=[
        pitchtools.Multiplication(
            n=3,
            ),
        ],
    )

Returns new compound operator.

CompoundOperator.retrograde(period=None)

Configures compound operator to retrograde pitches.

>>> operator = pitchtools.CompoundOperator()
>>> operator = operator.retrograde()
>>> f(operator)
pitchtools.CompoundOperator(
    operators=[
        pitchtools.Retrograde(),
        ],
    )

Returns new compound operator.

CompoundOperator.rotate(n=0, period=None, stravinsky=None)

Configures compound operator to rotate pitches by index n.

>>> operator = pitchtools.CompoundOperator()
>>> operator = operator.rotate(n=-1)
>>> f(operator)
pitchtools.CompoundOperator(
    operators=[
        pitchtools.Rotation(
            n=-1,
            ),
        ],
    )

Returns new compound operator.

CompoundOperator.transpose(n=0)

Configures compound operator to transpose pitches by index n.

>>> operator = pitchtools.CompoundOperator()
>>> operator = operator.transpose(n=1)
>>> f(operator)
pitchtools.CompoundOperator(
    operators=[
        pitchtools.Transposition(
            n=1,
            ),
        ],
    )

Returns new compound operator.

Special methods

CompoundOperator.__add__(operator)

Composes compound operator and operator.

>>> operator = pitchtools.CompoundOperator()
>>> operator = operator.transpose(n=1)
>>> operator = operator.multiply(n=5)
>>> str(operator)
'M5T1'
>>> inversion = pitchtools.Inversion()
>>> retrograde = pitchtools.Retrograde()
>>> transposition = pitchtools.Transposition(n=1)
>>> operator_1 = inversion + retrograde
>>> str(operator_1)
'IR'
>>> operator_2 = inversion + transposition
>>> str(operator_2)
'IT1'
>>> operator_3 = operator_1 + operator_2
>>> str(operator_3)
'IRIT1'
>>> f(operator_3)
pitchtools.CompoundOperator(
    operators=[
        pitchtools.Transposition(
            n=1,
            ),
        pitchtools.Inversion(),
        pitchtools.Retrograde(),
        pitchtools.Inversion(),
        ],
    )

Returns new compound operator.

CompoundOperator.__call__(argument)

Calls compound operator on argument.

>>> operator = pitchtools.CompoundOperator()
>>> operator = operator.rotate(n=1, stravinsky=True)
>>> operator = operator.transpose(n=2)
>>> str(operator)
'T2rs1'
>>> segment = pitchtools.PitchClassSegment([0, 1, 4, 7])
>>> show(segment) 
>>> transform = operator(segment)
>>> show(transform) 
>>> transform
PitchClassSegment([2, 7, 8, 11])

Returns new object with type equal to that of argument.

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

(AbjadValueObject).__eq__(argument)

Is true when all initialization values of Abjad value object equal the initialization values of argument.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to ‘’ or ‘storage’. Interprets ‘’ equal to ‘storage’.

Returns string.

(AbjadValueObject).__hash__()

Hashes Abjad value object.

Returns integer.

(AbjadObject).__ne__(argument)

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

Returns true or false.

CompoundOperator.__radd__(operator)

Composes operator and compound operator.

Returns new compound operator.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

CompoundOperator.__str__()

Gets string representation of compound operator.

Gets string:

>>> operator = pitchtools.CompoundOperator()
>>> operator = operator.rotate(n=1)
>>> operator = operator.transpose(n=2)
>>> str(operator)
'T2r1'

Gets string of empty operator:

>>> operator = pitchtools.CompoundOperator()
>>> str(operator)
''

Returns string.