Rotation

class pitchtools.Rotation(n=0, period=None, stravinsky=None)

Rotation operator.

>>> import abjad
>>> import pytest
>>> abjad.Rotation()
Rotation(n=0)
>>> abjad.Rotation(n=1)
Rotation(n=1)

Object model of the twelve-tone rotation operator.

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.Rotation.Rotation" [color=black, fontcolor=white, group=2, label=<<B>Rotation</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.Rotation.Rotation"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

n Gets index of rotation.
period Gets period of rotation.
stravinsky Is true when rotation uses Stravinsky-style back-transposition to zero.
__add__(operator) Composes rotation and operator.
__call__(argument) Calls rotation 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) Right-addition not defined on rotation.
__repr__() Gets interpreter representation of Abjad object.
__str__() Gets string representation of operator.

Read-only properties

Rotation.n

Gets index of rotation.

>>> rotation = abjad.Rotation()
>>> rotation.n
0
>>> rotation = abjad.Rotation(n=2)
>>> rotation.n
2

Returns integer.

Rotation.period

Gets period of rotation.

Todo

Deprecated.

>>> rotation = abjad.Rotation(n=2, period=3)
>>> rotation.period
3

Returns integer or none.

Rotation.stravinsky

Is true when rotation uses Stravinsky-style back-transposition to zero. Otherwise false.

>>> rotation = abjad.Rotation(n=2, stravinsky=False)
>>> rotation.stravinsky
False

Returns true or false.

Special methods

Rotation.__add__(operator)

Composes rotation and operator.

Example segment:

>>> items = [0, 2, 4, 5]
>>> segment = abjad.PitchClassSegment(items=items)
>>> show(segment) 

Example operators:

>>> rotation = abjad.Rotation(n=-1)
>>> transposition = abjad.Transposition(n=3)

Transposition followed by rotation:

>>> operator = rotation + transposition
>>> str(operator)
'r-1T3'
>>> segment_ = operator(segment)
>>> show(segment_) 

Same as above because rotation and transposition commute:

>>> operator = transposition + rotation
>>> str(operator)
'T3r-1'
>>> segment_ = operator(segment)
>>> show(segment_) 

Returns compound operator:

>>> f(operator)
abjad.CompoundOperator(
    operators=[
        abjad.Rotation(
            n=-1,
            ),
        abjad.Transposition(
            n=3,
            ),
        ],
    )
Rotation.__call__(argument)

Calls rotation on argument.

Rotates pitch classes:

>>> rotation = abjad.Rotation(n=1)
>>> pitch_classes = abjad.PitchClassSegment([0, 1, 4, 7])
>>> rotation(pitch_classes)
PitchClassSegment([7, 0, 1, 4])

Rotates pitch classes with Stravinsky-style back-transposition to zero:

>>> rotation = abjad.Rotation(n=1, stravinsky=True)
>>> pitch_classes = abjad.PitchClassSegment([0, 1, 4, 7])
>>> rotation(pitch_classes)
PitchClassSegment([0, 5, 6, 9])

Does not rotate single pitches or pitch-classes:

>>> rotation = abjad.Rotation(n=1)
>>> pitch_class = abjad.NumberedPitchClass(6)
>>> rotation(pitch_class)
NumberedPitchClass(6)

Periodic rotation:

Todo

Deprecated.

>>> rotation = abjad.Rotation(n=1, period=3)
>>> pitches = abjad.PitchSegment("c' d' e' f' g' a' b' c''")
>>> rotation(pitches)
PitchSegment("e' c' d' a' f' g' c'' b'")

Stravinsky-style periodic rotation:

Todo

Deprecated.

>>> rotation = abjad.Rotation(
...     n=1,
...     period=3,
...     stravinsky=True,
...     )
>>> pitches = abjad.PitchSegment("c' d' e' f' g' a' b' c''")
>>> rotation(pitches)
PitchSegment("c' af bf f' df' ef' b' as'")

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.

Rotation.__radd__(operator)

Right-addition not defined on rotation.

>>> string = 'abjad.Rotation().__radd__(abjad.Rotation())'
>>> pytest.raises(NotImplementedError, string)
<ExceptionInfo NotImplementedError tblen=3>

Raises not implemented error.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

Rotation.__str__()

Gets string representation of operator.

>>> str(abjad.Rotation())
'r0'
>>> str(abjad.Rotation(n=1))
'r1'
>>> str(abjad.Rotation(stravinsky=True))
'rs0'
>>> str(abjad.Rotation(n=1, stravinsky=True))
'rs1'