FixedDurationTuplet

class scoretools.FixedDurationTuplet(duration=Duration(1, 4), music="c'8 c'8 c'8")

A tuplet with fixed duration and variable multiplier.

>>> tuplet = scoretools.FixedDurationTuplet(Duration(2, 8), [])
>>> tuplet.extend("c'8 d'8 e'8")
>>> show(tuplet) 
>>> tuplet.append("fs'4")
>>> show(tuplet) 

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_scoretools { graph [label=scoretools]; "abjad.tools.scoretools.Component.Component" [color=3, group=2, label=Component, shape=oval, style=bold]; "abjad.tools.scoretools.Container.Container" [color=3, group=2, label=Container, shape=box]; "abjad.tools.scoretools.FixedDurationTuplet.FixedDurationTuplet" [color=black, fontcolor=white, group=2, label=<<B>FixedDurationTuplet</B>>, shape=box, style="filled, rounded"]; "abjad.tools.scoretools.Tuplet.Tuplet" [color=3, group=2, label=Tuplet, shape=box]; "abjad.tools.scoretools.Component.Component" -> "abjad.tools.scoretools.Container.Container"; "abjad.tools.scoretools.Container.Container" -> "abjad.tools.scoretools.Tuplet.Tuplet"; "abjad.tools.scoretools.Tuplet.Tuplet" -> "abjad.tools.scoretools.FixedDurationTuplet.FixedDurationTuplet"; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.scoretools.Component.Component"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Attribute summary

append(component) Appends component to container.
extend(expr) Extends container with expr.
force_fraction Gets and sets flag to force fraction formatting of tuplet.
force_times_command Is true when trivial tuplets print LilyPond \times command.
from_duration_and_ratio(duration, ratio[, ...]) Makes tuplet from duration and ratio.
from_leaf_and_ratio(leaf, ratio[, is_diminution]) Makes tuplet from leaf and ratio.
from_nonreduced_ratio_and_nonreduced_fraction(...) Makes tuplet from nonreduced ratio and nonreduced fraction.
implied_prolation Gets implied prolation of tuplet.
index(component) Returns index of component in container.
insert(i, component[, fracture_spanners]) Inserts component at index i in container.
is_augmentation Is true when tuplet multiplier is greater than 1.
is_diminution Is true when tuplet multiplier is less than 1.
is_invisible Gets and sets invisibility status of tuplet.
is_redundant Is true when tuplet is redundant.
is_simultaneous Is true when container is simultaneous.
is_trivial Is true when tuplet multiplier is equal to 1.
multiplied_duration Gets multiplied duration of tuplet.
multiplier Gets and sets multiplier of fixed-duration tuplet.
name Gets and sets name of container.
pop([i]) Pops component from container at index i.
preferred_denominator Gets and sets preferred denominator of tuplet.
remove(component) Removes component from container.
reverse() Reverses contents of container.
set_minimum_denominator(denominator) Sets preferred denominator of tuplet to at least denominator.
target_duration Gets and sets target duration of fixed-duration tuplet.
to_fixed_duration_tuplet() Changes tuplet to fixed-duration tuplet.
to_fixed_multiplier() Changes fixed-duration tuplet to (unqualified) tuplet.
toggle_prolation() Toggles prolation of fixed-duration tuplet.
trim(start[, stop]) Trims fixed-duration tuplet elements from start to stop:
__contains__(expr) Is true when expr appears in container.
__copy__(\*args) Copies component with indicators but without children of component or spanners attached to component.
__delitem__(i) Deletes components(s) at index i in container.
__eq__(expr) Is true when ID of expr equals ID of Abjad object.
__format__([format_specification]) Formats component.
__getitem__(i) Gets container i.
__graph__([spanner]) Graphviz graph representation of container.
__hash__() Hashes Abjad object.
__illustrate__() Illustrates component.
__iter__() Iterates container.
__len__() Gets number of items in container.
__mul__(n) Copies component n times and detaches spanners.
__ne__(expr) Is true when Abjad object does not equal expr.
__repr__() Gets interpreter representation of fixed-duration tuplet.
__rmul__(n) Copies component n times and detach spanners.
__setitem__(i, expr) Sets container i equal to expr.

Read-only properties

(Tuplet).implied_prolation

Gets implied prolation of tuplet.

>>> tuplet = Tuplet((2, 3), "c'8 d'8 e'8")
>>> show(tuplet) 
>>> tuplet.implied_prolation
Multiplier(2, 3)

Defined equal to tuplet multiplier.

Returns multiplier.

(Tuplet).is_augmentation

Is true when tuplet multiplier is greater than 1. Otherwise false.

Example 1. Augmented tuplet:

>>> tuplet = Tuplet((4, 3), "c'8 d'8 e'8")
>>> show(tuplet) 
>>> tuplet.is_augmentation
True

Example 2. Diminished tuplet:

>>> tuplet = Tuplet((2, 3), "c'4 d'4 e'4")
>>> show(tuplet) 
>>> tuplet.is_augmentation
False

Example 3. Trivial tuplet:

>>> tuplet = Tuplet((1, 1), "c'8. d'8. e'8.")
>>> show(tuplet) 
>>> tuplet.is_augmentation
False

Returns true or false.

(Tuplet).is_diminution

Is true when tuplet multiplier is less than 1. Otherwise false.

Example 1. Augmented tuplet:

>>> tuplet = Tuplet((4, 3), "c'8 d'8 e'8")
>>> show(tuplet) 
>>> tuplet.is_diminution
False

Example 2. Diminished tuplet:

>>> tuplet = Tuplet((2, 3), "c'4 d'4 e'4")
>>> show(tuplet) 
>>> tuplet.is_diminution
True

Example 3. Trivial tuplet:

>>> tuplet = Tuplet((1, 1), "c'8. d'8. e'8.")
>>> show(tuplet) 
>>> tuplet.is_diminution
False

Returns true or false.

(Tuplet).is_redundant

Is true when tuplet is redundant. Otherwise false.

Two conditions must be true for Abjad to identify a tuplet as redundant. First, the tuplet must contain only leaves (not other tuplets). Second, the durations of all leaves contained in the tuplet must be able to be rewritten without a tuplet bracket.

Example 1. Redudant tuplet:

>>> tuplet = Tuplet(Multiplier(3, 4), "c'4 c'4")
>>> measure = Measure((3, 8), [tuplet])
>>> show(measure) 
>>> tuplet.is_redundant
True

Can be rewritten without a tuplet bracket:

>>> measure = Measure((3, 8), "c'8. c'8.")
>>> show(measure) 

Example 2. Nonredundant tuplet:

>>> tuplet = Tuplet(Multiplier(3, 5), "c'4 c'4 c'4 c'4 c'4")
>>> measure = Measure((3, 4), [tuplet])
>>> show(measure) 
>>> tuplet.is_redundant
False

Can not be rewritten without a tuplet bracket.

Returns true or false.

(Tuplet).is_trivial

Is true when tuplet multiplier is equal to 1. Otherwise false:

>>> tuplet = Tuplet((1, 1), "c'8 d'8 e'8")
>>> show(tuplet) 
>>> tuplet.is_trivial
True

Returns true or false.

FixedDurationTuplet.multiplied_duration

Gets multiplied duration of tuplet.

>>> tuplet = scoretools.FixedDurationTuplet((1, 4), "c'8 d'8 e'8")
>>> tuplet.multiplied_duration
Duration(1, 4)

Returns duration.

Read/write properties

(Tuplet).force_fraction

Gets and sets flag to force fraction formatting of tuplet.

Example 1. Gets forced fraction formatting of tuplet:

>>> tuplet = Tuplet((2, 3), "c'8 d'8 e'8")
>>> show(tuplet) 
>>> tuplet.force_fraction
False

Example 2. Sets forced fraction formatting of tuplet:

>>> tuplet.force_fraction = True
>>> show(tuplet) 

Example 3. Ignored when tuplet number text is overridden explicitly:

>>> tuplet = Tuplet((2, 3), "c'8 d'8 e'8")
>>> duration = inspect_(tuplet).get_duration()
>>> markup = duration.to_score_markup()
>>> override(tuplet).tuplet_number.text = markup
>>> staff = Staff([tuplet])
>>> show(staff) 

Returns boolean or none.

(Tuplet).force_times_command

Is true when trivial tuplets print LilyPond \times command. Otherwise false.

Example 1. Trivial tuplets normally print as a LilyPond container enclosed in { and } but without the LilyPond \times command:

>>> trivial_tuplet = Tuplet((1, 1), "c'4 d' e'")
>>> trivial_tuplet.force_times_command
False
>>> f(trivial_tuplet)
{
    c'4
    d'4
    e'4
}
>>> show(trivial_tuplet) 

Example 2. But it is possible to force a trivial tuplet to format the LilyPond \times command:

>>> trivial_tuplet = Tuplet((1, 1), "c'4 d' e'")
>>> trivial_tuplet.force_times_command = True
>>> f(trivial_tuplet)
\times 1/1 {
    c'4
    d'4
    e'4
}
>>> show(trivial_tuplet) 

Example 3. This makes it possible to override tuplet number text:

>>> trivial_tuplet = Tuplet((1, 1), "c'4 d' e'")
>>> trivial_tuplet.force_times_command = True
>>> duration = inspect_(trivial_tuplet).get_duration()
>>> markup = duration.to_score_markup()
>>> markup = markup.scale((0.75, 0.75))
>>> override(trivial_tuplet).tuplet_number.text = markup
>>> staff = Staff([trivial_tuplet])
>>> show(staff) 

Defaults to false.

Set to true or false.

Returns true or false.

(Tuplet).is_invisible

Gets and sets invisibility status of tuplet.

Example 1. Gets tuplet invisibility flag:

>>> tuplet = Tuplet((2, 3), "c'8 d'8 e'8")
>>> show(tuplet) 
>>> tuplet.is_invisible
False

Example 2. Sets tuplet invisibility flag:

>>> tuplet_1 = Tuplet((2, 3), "c'4 d'4 e'4")
>>> tuplet_2 = Tuplet((2, 3), "d'4 e'4 f'4")
>>> staff = Staff([tuplet_1, tuplet_2])
>>> show(staff) 
>>> staff[0].is_invisible = True
>>> show(staff) 

Hides tuplet bracket and tuplet number when true.

Preserves tuplet duration when true.

Returns boolean or none.

(Container).is_simultaneous

Is true when container is simultaneous. Otherwise false.

Example 1. Gets simultaneity status of container:

>>> container = Container()
>>> container.append(Voice("c'8 d'8 e'8"))
>>> container.append(Voice('g4.'))
>>> show(container) 
>>> container.is_simultaneous
False

Example 2. Sets simultaneity status of container:

>>> container = Container()
>>> container.append(Voice("c'8 d'8 e'8"))
>>> container.append(Voice('g4.'))
>>> show(container) 
>>> container.is_simultaneous = True
>>> show(container) 

Defaults to false.

Set to true or false.

Returns true or false.

FixedDurationTuplet.multiplier

Gets and sets multiplier of fixed-duration tuplet.

>>> tuplet = scoretools.FixedDurationTuplet(
...     (1, 4), "c'8 d'8 e'8")
>>> tuplet.multiplier
Multiplier(2, 3)

Returns multiplier.

(Container).name

Gets and sets name of container.

Example 1. Gets container name:

>>> container = Container("c'4 d'4 e'4 f'4")
>>> show(container) 
>>> container.name is None
True

Example 2. Sets container name:

>>> container = Container("c'4 d'4 e'4 f'4", name='Special')
>>> show(container) 
>>> container.name
'Special'

Container name does not appear in LilyPond output:

>>> f(container)
{
    c'4
    d'4
    e'4
    f'4
}

Defaults to none.

Set to string or none.

Returns string or none.

(Tuplet).preferred_denominator

Gets and sets preferred denominator of tuplet.

Example 1. Gets preferred denominator of tuplet:

>>> tuplet = Tuplet((2, 3), "c'8 d'8 e'8")
>>> tuplet.preferred_denominator is None
True
>>> show(tuplet) 

Example 2. Sets preferred denominator of tuplet:

>>> tuplet = Tuplet((2, 3), "c'8 d'8 e'8")
>>> show(tuplet) 
>>> tuplet.preferred_denominator = 4
>>> show(tuplet) 

Returns positive integer or none.

FixedDurationTuplet.target_duration

Gets and sets target duration of fixed-duration tuplet.

>>> tuplet = scoretools.FixedDurationTuplet(
...     (1, 4), "c'8 d'8 e'8")
>>> tuplet.target_duration
Duration(1, 4)
>>> tuplet.target_duration = Duration(5, 8)
>>> print(format(tuplet))
\tweak text #tuplet-number::calc-fraction-text
\times 5/3 {
    c'8
    d'8
    e'8
}

Returns duration.

Methods

(Container).append(component)

Appends component to container.

Example 1. Appends note to container:

>>> container = Container("c'4 ( d'4 f'4 )")
>>> show(container) 
>>> container.append(Note("e'4"))
>>> show(container) 

Returns none.

(Container).extend(expr)

Extends container with expr.

Example 1. Extends container with three notes:

>>> container = Container("c'4 ( d'4 f'4 )")
>>> show(container) 
>>> notes = [Note("e'32"), Note("d'32"), Note("e'16")]
>>> container.extend(notes)
>>> show(container) 

Returns none.

(Container).index(component)

Returns index of component in container.

Example 1. Gets index of last element in container:

>>> container = Container("c'4 d'4 f'4 e'4")
>>> show(container) 
>>> note = container[-1]
>>> note
Note("e'4")
>>> container.index(note)
3

Returns nonnegative integer.

(Container).insert(i, component, fracture_spanners=False)

Inserts component at index i in container.

Example 1. Inserts note. Does not fracture spanners:

>>> container = Container([])
>>> container.extend("fs16 cs' e' a'")
>>> container.extend("cs''16 e'' cs'' a'")
>>> container.extend("fs'16 e' cs' fs")
>>> slur = spannertools.Slur(direction=Down)
>>> attach(slur, container[:])
>>> show(container) 
>>> container.insert(-4, Note("e'4"), fracture_spanners=False)
>>> show(container) 

Example 2. Inserts note. Fractures spanners:

>>> container = Container([])
>>> container.extend("fs16 cs' e' a'")
>>> container.extend("cs''16 e'' cs'' a'")
>>> container.extend("fs'16 e' cs' fs")
>>> slur = spannertools.Slur(direction=Down)
>>> attach(slur, container[:])
>>> show(container) 
>>> container.insert(-4, Note("e'4"), fracture_spanners=True)
>>> show(container) 

Returns none.

(Container).pop(i=-1)

Pops component from container at index i.

Example 1. Pops last element from container:

>>> container = Container("c'4 ( d'4 f'4 ) e'4")
>>> show(container) 
>>> container.pop()
Note("e'4")
>>> show(container) 

Returns component.

(Container).remove(component)

Removes component from container.

Example 1. Removes note from container:

>>> container = Container("c'4 ( d'4 f'4 ) e'4")
>>> show(container) 
>>> note = container[2]
>>> note
Note("f'4")
>>> container.remove(note)
>>> show(container) 

Returns none.

(Container).reverse()

Reverses contents of container.

Example 1. Reverses staff:

>>> staff = Staff("c'8 [ d'8 ] e'8 ( f'8 )")
>>> show(staff) 
>>> staff.reverse()
>>> show(staff) 

Returns none.

(Tuplet).set_minimum_denominator(denominator)

Sets preferred denominator of tuplet to at least denominator.

Example 1. Sets preferred denominator of tuplet to 8 at least:

>>> tuplet = Tuplet((3, 5), "c'4 d'8 e'8 f'4 g'2")
>>> show(tuplet) 
>>> tuplet.set_minimum_denominator(8)
>>> show(tuplet) 

Returns none.

(Tuplet).to_fixed_duration_tuplet()

Changes tuplet to fixed-duration tuplet.

Example 1. Changes tuplet to fixed-duration tuplet:

>>> tuplet = Tuplet((2, 3), "c'8 d'8 e'8")
>>> show(tuplet) 
>>> tuplet
Tuplet(Multiplier(2, 3), "c'8 d'8 e'8")
>>> new_tuplet = tuplet.to_fixed_duration_tuplet()
>>> show(new_tuplet) 
>>> new_tuplet
FixedDurationTuplet(Duration(1, 4), "c'8 d'8 e'8")

Returns new tuplet.

FixedDurationTuplet.to_fixed_multiplier()

Changes fixed-duration tuplet to (unqualified) tuplet.

>>> tuplet = scoretools.FixedDurationTuplet((2, 8), [])
>>> tuplet.extend("c'8 d'8 e'8")
>>> show(tuplet) 
>>> tuplet
FixedDurationTuplet(Duration(1, 4), "c'8 d'8 e'8")
>>> new_tuplet = tuplet.to_fixed_multiplier()
>>> show(new_tuplet) 
>>> new_tuplet
Tuplet(Multiplier(2, 3), "c'8 d'8 e'8")

Returns new tuplet.

FixedDurationTuplet.toggle_prolation()

Toggles prolation of fixed-duration tuplet.

>>> tuplet = scoretools.FixedDurationTuplet((1, 4), "c'8 d'8 e'8")
>>> show(tuplet) 
>>> tuplet.toggle_prolation()
>>> show(tuplet) 
>>> tuplet.toggle_prolation()
>>> show(tuplet) 

Returns none.

FixedDurationTuplet.trim(start, stop='unused')

Trims fixed-duration tuplet elements from start to stop:

>>> tuplet = scoretools.FixedDurationTuplet(
...     Duration(2, 8), "c'8 d'8 e'8")
>>> tuplet
FixedDurationTuplet(Duration(1, 4), "c'8 d'8 e'8")
>>> tuplet.trim(2)
>>> tuplet
FixedDurationTuplet(Duration(1, 6), "c'8 d'8")

Preserves fixed-duration tuplet multiplier.

Adjusts fixed-duration tuplet duration.

Returns none.

Class & static methods

(Tuplet).from_duration_and_ratio(duration, ratio, avoid_dots=True, decrease_durations_monotonically=True, is_diminution=True)

Makes tuplet from duration and ratio.

Example 1. Makes augmented tuplet from duration and ratio and avoid dots.

Makes tupletted leaves strictly without dots when all ratio equal 1:

>>> tuplet = Tuplet.from_duration_and_ratio(
...     Duration(3, 16),
...     mathtools.Ratio((1, 1, 1, -1, -1)),
...     avoid_dots=True,
...     is_diminution=False,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Allows tupletted leaves to return with dots when some ratio do not equal 1:

>>> tuplet = Tuplet.from_duration_and_ratio(
...     Duration(3, 16),
...     mathtools.Ratio((1, -2, -2, 3, 3)),
...     avoid_dots=True,
...     is_diminution=False,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Interprets nonassignable ratio according to decrease_durations_monotonically:

>>> tuplet = Tuplet.from_duration_and_ratio(
...     Duration(3, 16),
...     mathtools.Ratio((5, -1, 5)),
...     avoid_dots=True,
...     decrease_durations_monotonically=False,
...     is_diminution=False,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Example 2. Makes augmented tuplet from duration and ratio and encourages dots:

>>> tuplet = Tuplet.from_duration_and_ratio(
...     Duration(3, 16),
...     mathtools.Ratio((1, 1, 1, -1, -1)),
...     avoid_dots=False,
...     is_diminution=False,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Interprets nonassignable ratio according to decrease_durations_monotonically:

>>> tuplet = Tuplet.from_duration_and_ratio(
...     Duration(3, 16),
...     mathtools.Ratio((5, -1, 5)),
...     avoid_dots=False,
...     decrease_durations_monotonically=False,
...     is_diminution=False,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Example 3. Makes diminished tuplet from duration and nonzero integer ratio.

Makes tupletted leaves strictly without dots when all ratio equal 1:

>>> tuplet = Tuplet.from_duration_and_ratio(
...     Duration(3, 16),
...     mathtools.Ratio((1, 1, 1, -1, -1)),
...     avoid_dots=True,
...     is_diminution=True,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Allows tupletted leaves to return with dots when some ratio do not equal 1:

>>> tuplet = Tuplet.from_duration_and_ratio(
...     Duration(3, 16),
...     mathtools.Ratio((1, -2, -2, 3, 3)),
...     avoid_dots=True,
...     is_diminution=True,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Interprets nonassignable ratio according to decrease_durations_monotonically:

>>> tuplet = Tuplet.from_duration_and_ratio(
...     Duration(3, 16),
...     mathtools.Ratio((5, -1, 5)),
...     avoid_dots=True,
...     decrease_durations_monotonically=False,
...     is_diminution=True,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Example 4. Makes diminished tuplet from duration and ratio and encourages dots:

>>> tuplet = Tuplet.from_duration_and_ratio(
...     Duration(3, 16),
...     mathtools.Ratio((1, 1, 1, -1, -1)),
...     avoid_dots=False,
...     is_diminution=True,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Interprets nonassignable ratio according to direction:

>>> tuplet = Tuplet.from_duration_and_ratio(
...     Duration(3, 16),
...     mathtools.Ratio((5, -1, 5)),
...     avoid_dots=False,
...     decrease_durations_monotonically=False,
...     is_diminution=True,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(measure) 

Reduces ratio relative to each other.

Interprets negative ratio as rests.

Returns fixed-duration tuplet.

(Tuplet).from_leaf_and_ratio(leaf, ratio, is_diminution=True)

Makes tuplet from leaf and ratio.

>>> note = Note("c'8.")

Example 1a. Changes leaf to augmented tuplets with ratio:

>>> tuplet = Tuplet.from_leaf_and_ratio(
...     note,
...     mathtools.Ratio((1,)),
...     is_diminution=False,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Example 1b. Changes leaf to augmented tuplets with ratio:

>>> tuplet = Tuplet.from_leaf_and_ratio(
...     note,
...     [1, 2],
...     is_diminution=False,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Example 1c. Changes leaf to augmented tuplets with ratio:

>>> tuplet = Tuplet.from_leaf_and_ratio(
...     note,
...     mathtools.Ratio((1, 2, 2)),
...     is_diminution=False,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Example 1d. Changes leaf to augmented tuplets with ratio:

>>> tuplet = Tuplet.from_leaf_and_ratio(
...     note,
...     [1, 2, 2, 3],
...     is_diminution=False,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Example 1e. Changes leaf to augmented tuplets with ratio:

>>> tuplet = Tuplet.from_leaf_and_ratio(
...     note,
...     [1, 2, 2, 3, 3],
...     is_diminution=False,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Example 1f. Changes leaf to augmented tuplets with ratio:

>>> tuplet = Tuplet.from_leaf_and_ratio(
...     note,
...     mathtools.Ratio((1, 2, 2, 3, 3, 4)),
...     is_diminution=False,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Example 2a. Changes leaf to diminished tuplets with ratio:

>>> tuplet = Tuplet.from_leaf_and_ratio(
...     note,
...     [1],
...     is_diminution=True,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Example 2b. Changes leaf to diminished tuplets with ratio:

>>> tuplet = Tuplet.from_leaf_and_ratio(
...     note,
...     [1, 2],
...     is_diminution=True,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Example 2c. Changes leaf to diminished tuplets with ratio:

>>> tuplet = Tuplet.from_leaf_and_ratio(
...     note,
...     [1, 2, 2],
...     is_diminution=True,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Example 2d. Changes leaf to diminished tuplets with ratio:

>>> tuplet = Tuplet.from_leaf_and_ratio(
...     note,
...     [1, 2, 2, 3],
...     is_diminution=True,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Example 2e. Changes leaf to diminished tuplets with ratio:

>>> tuplet = Tuplet.from_leaf_and_ratio(
...     note,
...     [1, 2, 2, 3, 3],
...     is_diminution=True,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Example 2f. Changes leaf to diminished tuplets with ratio:

>>> tuplet = Tuplet.from_leaf_and_ratio(
...     note,
...     [1, 2, 2, 3, 3, 4],
...     is_diminution=True,
...     )
>>> measure = Measure((3, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Returns tuplet.

(Tuplet).from_nonreduced_ratio_and_nonreduced_fraction(ratio, fraction)

Makes tuplet from nonreduced ratio and nonreduced fraction.

Example 1. Makes container when no prolation is necessary:

>>> tuplet = Tuplet.from_nonreduced_ratio_and_nonreduced_fraction(
...     mathtools.NonreducedRatio((1,)),
...     mathtools.NonreducedFraction(7, 16),
...     )
>>> measure = Measure((7, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Example 2. Makes fixed-duration tuplet when prolation is necessary:

>>> tuplet = Tuplet.from_nonreduced_ratio_and_nonreduced_fraction(
...     mathtools.NonreducedRatio((1, 2)),
...     mathtools.NonreducedFraction(7, 16),
...     )
>>> measure = Measure((7, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 
>>> tuplet = Tuplet.from_nonreduced_ratio_and_nonreduced_fraction(
...     mathtools.NonreducedRatio((1, 2, 4)),
...     mathtools.NonreducedFraction(7, 16),
...     )
>>> measure = Measure((7, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 
>>> tuplet = Tuplet.from_nonreduced_ratio_and_nonreduced_fraction(
...     mathtools.NonreducedRatio((1, 2, 4, 1)),
...     mathtools.NonreducedFraction(7, 16),
...     )
>>> measure = Measure((7, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 
>>> tuplet = Tuplet.from_nonreduced_ratio_and_nonreduced_fraction(
...     mathtools.NonreducedRatio((1, 2, 4, 1, 2)),
...     mathtools.NonreducedFraction(7, 16),
...     )
>>> measure = Measure((7, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 
>>> tuplet = Tuplet.from_nonreduced_ratio_and_nonreduced_fraction(
...     mathtools.NonreducedRatio((1, 2, 4, 1, 2, 4)),
...     mathtools.NonreducedFraction(7, 16),
...     )
>>> measure = Measure((7, 16), [tuplet])
>>> staff = Staff([measure])
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Interprets d as tuplet denominator.

Returns tuplet or container.

Special methods

(Container).__contains__(expr)

Is true when expr appears in container. Otherwise false.

Returns true or false.

(Component).__copy__(*args)

Copies component with indicators but without children of component or spanners attached to component.

Returns new component.

(Container).__delitem__(i)

Deletes components(s) at index i in container.

Example 1. Deletes first tuplet in voice:

>>> voice = Voice()
>>> voice.append(Tuplet((2, 3), "c'4 d'4 e'4"))
>>> voice.append(Tuplet((2, 3), "e'4 d'4 c'4"))
>>> leaves = iterate(voice).by_class(scoretools.Leaf)
>>> attach(Slur(), list(leaves))
>>> show(voice) 
>>> tuplet_1 = voice[0]
>>> del(voice[0])

First tuplet no longer appears in voice:

>>> show(voice) 
>>> inspect_(voice).is_well_formed()
True

First tuplet is no longer slurred but is still well-formed:

>>> show(tuplet_1) 
>>> inspect_(tuplet_1).is_well_formed()
True

Withdraws component(s) from crossing spanners.

Preserves spanners that component(s) cover(s).

Returns none.

(AbjadObject).__eq__(expr)

Is true when ID of expr equals ID of Abjad object. Otherwise false.

Returns true or false.

(Component).__format__(format_specification='')

Formats component.

Set format_specification to ‘’, ‘lilypond’ or ‘storage’.

Returns string.

(Container).__getitem__(i)

Gets container i.

Traverses top-level items only.

Returns component.

(Container).__graph__(spanner=None, **kwargs)

Graphviz graph representation of container.

Returns Graphviz graph.

(AbjadObject).__hash__()

Hashes Abjad object.

Required to be explicitly redefined on Python 3 if __eq__ changes.

Returns integer.

(Component).__illustrate__()

Illustrates component.

Returns LilyPond file.

(Container).__iter__()

Iterates container.

Example 1. Abjad containers are iterables:

>>> import collections
>>> container = Container()
>>> isinstance(container, collections.Iterable)
True

Example 2. Abjad containers are not sequences:

>>> import collections
>>> container = Container()
>>> isinstance(container, collections.Sequence)
False

Yields container elements.

Returns generator.

(Container).__len__()

Gets number of items in container.

Returns nonnegative integer.

(Component).__mul__(n)

Copies component n times and detaches spanners.

Returns list of new components.

(AbjadObject).__ne__(expr)

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

Returns true or false.

FixedDurationTuplet.__repr__()

Gets interpreter representation of fixed-duration tuplet.

Returns string.

(Component).__rmul__(n)

Copies component n times and detach spanners.

Returns list of new components.

(Container).__setitem__(i, expr)

Sets container i equal to expr. Finds spanners that dominate self[i] and children of self[i]. Replaces contents at self[i] with ‘expr’. Reattaches spanners to new contents. Always leaves score tree in tact.

Returns none.