Offset

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.system" { graph [label="abjad.system"]; node [color=1]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/utilities/../system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; } subgraph "cluster_abjad.utilities" { graph [label="abjad.utilities"]; node [color=2]; "abjad.utilities.Duration.Duration" [URL="../api/abjad/utilities/Duration.html#abjad.utilities.Duration.Duration", label=Duration, target=_top]; "abjad.utilities.Offset.Offset" [URL="../api/abjad/utilities/Offset.html#abjad.utilities.Offset.Offset", color=black, fontcolor=white, label=Offset, target=_top]; "abjad.utilities.Duration.Duration" -> "abjad.utilities.Offset.Offset"; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } subgraph cluster_fractions { graph [label=fractions]; node [color=4]; "fractions.Fraction" [URL="https://docs.python.org/3.6/library/fractions.html#fractions.Fraction", label=Fraction, target=_top]; } subgraph cluster_numbers { graph [label=numbers]; node [color=5]; "numbers.Complex" [URL="https://docs.python.org/3.6/library/numbers.html#numbers.Complex", label=Complex, shape=oval, style=bold, target=_top]; "numbers.Number" [URL="https://docs.python.org/3.6/library/numbers.html#numbers.Number", label=Number, target=_top]; "numbers.Rational" [URL="https://docs.python.org/3.6/library/numbers.html#numbers.Rational", label=Rational, shape=oval, style=bold, target=_top]; "numbers.Real" [URL="https://docs.python.org/3.6/library/numbers.html#numbers.Real", label=Real, shape=oval, style=bold, target=_top]; "numbers.Complex" -> "numbers.Real"; "numbers.Number" -> "numbers.Complex"; "numbers.Real" -> "numbers.Rational"; } "abjad.system.AbjadObject.AbjadObject" -> "abjad.utilities.Duration.Duration"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; "builtins.object" -> "numbers.Number"; "fractions.Fraction" -> "abjad.utilities.Duration.Duration"; "numbers.Rational" -> "fractions.Fraction"; }

class abjad.utilities.Offset.Offset

Offset.

Initializes from integer numerator:

>>> abjad.Offset(3)
Offset(3, 1)

Initializes from integer numerator and denominator:

>>> abjad.Offset(3, 16)
Offset(3, 16)

Initializes from integer-equivalent numeric numerator:

>>> abjad.Offset(3.0)
Offset(3, 1)

Initializes from integer-equivalent numeric numerator and denominator:

>>> abjad.Offset(3.0, 16)
Offset(3, 16)

Initializes from integer-equivalent singleton:

>>> abjad.Offset((3,))
Offset(3, 1)

Initializes from integer-equivalent pair:

>>> abjad.Offset((3, 16))
Offset(3, 16)

Initializes from duration:

>>> abjad.Offset(abjad.Duration(3, 16))
Offset(3, 16)

Initializes from other offset:

>>> abjad.Offset(abjad.Offset(3, 16))
Offset(3, 16)

Initializes from other offset with grace displacement:

>>> offset = abjad.Offset((3, 16), grace_displacement=(-1, 16))
>>> abjad.Offset(offset)
Offset(
    (3, 16),
    grace_displacement=Duration(-1, 16)
    )

Intializes from fraction:

>>> abjad.Offset(abjad.Fraction(3, 16))
Offset(3, 16)

Initializes from solidus string:

>>> abjad.Offset('3/16')
Offset(3, 16)

Initializes from nonreduced fraction:

>>> abjad.Offset(abjad.NonreducedFraction(6, 32))
Offset(3, 16)

Offsets inherit from built-in fraction:

>>> isinstance(abjad.Offset(3, 16), abjad.Fraction)
True

Offsets are numbers:

>>> import numbers
>>> isinstance(abjad.Offset(3, 16), numbers.Number)
True

Attributes Summary

__copy__ Copies offset.
__deepcopy__ Deep copies offset.
__eq__ Is true when offset equals argument.
__ge__ Is true when offset is greater than or equal to argument.
__gt__ Is true when offset is greater than argument.
__hash__ Hashes offset.
__le__ Is true when offset is less than or equal to argument.
__lt__ Is true when offset is less than argument.
__new__ Create and return a new object.
__repr__ Gets interpreter representation of offset.
__sub__ Offset taken from offset returns duration:
grace_displacement Gets grace displacement.

Special methods

(Duration).__abs__(*arguments)

Gets absolute value of duration.

Returns nonnegative duration.

(Duration).__add__(*arguments)

Adds duration to arguments.

Returns duration when arguments is a duration:

>>> duration_1 = abjad.Duration(1, 2)
>>> duration_2 = abjad.Duration(3, 2)
>>> duration_1 + duration_2
Duration(2, 1)

Returns nonreduced fraction when arguments is a nonreduced fraction:

>>> duration = abjad.Duration(1, 2)
>>> nonreduced_fraction = abjad.NonreducedFraction(3, 6)
>>> duration + nonreduced_fraction
NonreducedFraction(6, 6)

Returns duration.

(Fraction).__bool__()

a != 0

(Fraction).__ceil__()

Will be math.ceil(a) in 3.0.

(Real).__complex__()

complex(self) == complex(float(self), 0)

__copy__(*arguments)

Copies offset.

>>> import copy

Copies offset with grace displacement:

>>> offset_1 = abjad.Offset((1, 4), grace_displacement=(-1, 16))
>>> offset_2 = copy.copy(offset_1)
>>> offset_1
Offset(
    (1, 4),
    grace_displacement=Duration(-1, 16)
    )
>>> offset_2
Offset(
    (1, 4),
    grace_displacement=Duration(-1, 16)
    )
>>> offset_1 == offset_2
True
>>> offset_1 is offset_2
False

Returns new offset.

__deepcopy__(*arguments)

Deep copies offset.

>>> import copy

Copies offset with grace displacement:

>>> offset_1 = abjad.Offset((1, 4), grace_displacement=(-1, 16))
>>> offset_2 = copy.deepcopy(offset_1)
>>> offset_1
Offset(
    (1, 4),
    grace_displacement=Duration(-1, 16)
    )
>>> offset_2
Offset(
    (1, 4),
    grace_displacement=Duration(-1, 16)
    )
>>> offset_1 == offset_2
True
>>> offset_1 is offset_2
False

Returns new offset.

(Duration).__div__(*arguments)

Divides duration by arguments.

>>> abjad.Duration(1) / abjad.NonreducedFraction(3, 3)
NonreducedFraction(3, 3)
>>> abjad.NonreducedFraction(3, 3) / abjad.Duration(1)
NonreducedFraction(3, 3)

Returns multiplier.

(Duration).__divmod__(*arguments)

Equals the pair (duration // arguments, duration % arguments).

Returns pair.

__eq__(argument)

Is true when offset equals argument.

With equal numerators, denominators and grace displacements:

>>> offset_1 = abjad.Offset((1, 4), grace_displacement=(-1, 16))
>>> offset_2 = abjad.Offset((1, 4), grace_displacement=(-1, 16))
>>> offset_1 == offset_1
True
>>> offset_1 == offset_2
True
>>> offset_2 == offset_1
True
>>> offset_2 == offset_2
True

With equal numerators and denominators but differing grace displacements:

>>> offset_1 = abjad.Offset((1, 4), grace_displacement=(-1, 8))
>>> offset_2 = abjad.Offset((1, 4), grace_displacement=(-1, 16))
>>> offset_1 == offset_1
True
>>> offset_1 == offset_2
False
>>> offset_2 == offset_1
False
>>> offset_2 == offset_2
True

With differing numerators and denominators. Ignores grace displacements:

>>> offset_1 = abjad.Offset((1, 4))
>>> offset_2 = abjad.Offset((1, 2), grace_displacement=(-99))
>>> offset_1 == offset_1
True
>>> offset_1 == offset_2
False
>>> offset_2 == offset_1
False
>>> offset_2 == offset_2
True

Returns true or false.

(Rational).__float__()

float(self) = self.numerator / self.denominator

It’s important that this conversion use the integer’s “true” division rather than casting one side to float before dividing so that ratios of huge integers convert without overflowing.

(Fraction).__floor__()

Will be math.floor(a) in 3.0.

(Fraction).__floordiv__(b)

a // b

(Duration).__format__(format_specification='')

Formats duration.

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

Returns string.

__ge__(argument)

Is true when offset is greater than or equal to argument.

With equal numerators, denominators and grace displacements:

>>> offset_1 = abjad.Offset((1, 4), grace_displacement=(-1, 16))
>>> offset_2 = abjad.Offset((1, 4), grace_displacement=(-1, 16))
>>> offset_1 >= offset_1
True
>>> offset_1 >= offset_2
True
>>> offset_2 >= offset_1
True
>>> offset_2 >= offset_2
True

With equal numerators and denominators but differing grace displacements:

>>> offset_1 = abjad.Offset((1, 4), grace_displacement=(-1, 8))
>>> offset_2 = abjad.Offset((1, 4), grace_displacement=(-1, 16))
>>> offset_1 >= offset_1
True
>>> offset_1 >= offset_2
False
>>> offset_2 >= offset_1
True
>>> offset_2 >= offset_2
True

With differing numerators and denominators. Ignores grace displacements:

>>> offset_1 = abjad.Offset((1, 4))
>>> offset_2 = abjad.Offset((1, 2), grace_displacement=(-99))
>>> offset_1 >= offset_1
True
>>> offset_1 >= offset_2
False
>>> offset_2 >= offset_1
True
>>> offset_2 >= offset_2
True

Returns true or false.

__gt__(argument)

Is true when offset is greater than argument.

With equal numerators, denominators and grace displacements:

>>> offset_1 = abjad.Offset((1, 4), grace_displacement=(-1, 16))
>>> offset_2 = abjad.Offset((1, 4), grace_displacement=(-1, 16))
>>> offset_1 > offset_1
False
>>> offset_1 > offset_2
False
>>> offset_2 > offset_1
False
>>> offset_2 > offset_2
False

With equal numerators and denominators but differing grace displacements:

>>> offset_1 = abjad.Offset((1, 4), grace_displacement=(-1, 8))
>>> offset_2 = abjad.Offset((1, 4), grace_displacement=(-1, 16))
>>> offset_1 > offset_1
False
>>> offset_1 > offset_2
False
>>> offset_2 > offset_1
True
>>> offset_2 > offset_2
False

With differing numerators and denominators. Ignores grace displacements:

>>> offset_1 = abjad.Offset((1, 4))
>>> offset_2 = abjad.Offset((1, 2), grace_displacement=(-99))
>>> offset_1 > offset_1
False
>>> offset_1 > offset_2
False
>>> offset_2 > offset_1
True
>>> offset_2 > offset_2
False

Returns true or false.

__hash__()

Hashes offset.

Redefined in tandem with __eq__.

__le__(argument)

Is true when offset is less than or equal to argument.

With equal numerators, denominators and grace displacements:

>>> offset_1 = abjad.Offset((1, 4), grace_displacement=(-1, 16))
>>> offset_2 = abjad.Offset((1, 4), grace_displacement=(-1, 16))
>>> offset_1 <= offset_1
True
>>> offset_1 <= offset_2
True
>>> offset_2 <= offset_1
True
>>> offset_2 <= offset_2
True

With equal numerators and denominators but differing grace displacements:

>>> offset_1 = abjad.Offset((1, 4), grace_displacement=(-1, 8))
>>> offset_2 = abjad.Offset((1, 4), grace_displacement=(-1, 16))
>>> offset_1 <= offset_1
True
>>> offset_1 <= offset_2
True
>>> offset_2 <= offset_1
False
>>> offset_2 <= offset_2
True

With differing numerators and denominators. Ignores grace displacements:

>>> offset_1 = abjad.Offset((1, 4))
>>> offset_2 = abjad.Offset((1, 2), grace_displacement=(-99))
>>> offset_1 <= offset_1
True
>>> offset_1 <= offset_2
True
>>> offset_2 <= offset_1
False
>>> offset_2 <= offset_2
True

Returns true or false.

__lt__(argument)

Is true when offset is less than argument.

With equal numerators, denominators and grace displacements:

>>> offset_1 = abjad.Offset((1, 4), grace_displacement=(-1, 16))
>>> offset_2 = abjad.Offset((1, 4), grace_displacement=(-1, 16))
>>> offset_1 < offset_1
False
>>> offset_1 < offset_2
False
>>> offset_2 < offset_1
False
>>> offset_2 < offset_2
False

With equal numerators and denominators but differing nonzero grace displacements:

>>> offset_1 = abjad.Offset((1, 4), grace_displacement=(-1, 8))
>>> offset_2 = abjad.Offset((1, 4), grace_displacement=(-1, 16))
>>> offset_1 < offset_1
False
>>> offset_1 < offset_2
True
>>> offset_2 < offset_1
False
>>> offset_2 < offset_2
False

With equal numerators and denominators but differing zero-valued grace displacements:

>>> offset_1 = abjad.Offset((1, 4), grace_displacement=(-1, 8))
>>> offset_2 = abjad.Offset((1, 4))
>>> offset_1 < offset_1
False
>>> offset_1 < offset_2
True
>>> offset_2 < offset_1
False
>>> offset_2 < offset_2
False

With differing numerators and denominators. Ignores grace displacements:

>>> offset_1 = abjad.Offset((1, 4))
>>> offset_2 = abjad.Offset((1, 2), grace_displacement=(-99))
>>> offset_1 < offset_1
False
>>> offset_1 < offset_2
True
>>> offset_2 < offset_1
False
>>> offset_2 < offset_2
False

Returns true or false.

(Duration).__mod__(*arguments)

Modulus operator applied to duration.

Returns duration.

(Duration).__mul__(*arguments)

Duration multiplied by arguments.

Returns a new duration when arguments is a duration:

>>> duration_1 = abjad.Duration(1, 2)
>>> duration_2 = abjad.Duration(3, 2)
>>> duration_1 * duration_2
Duration(3, 4)

Returns nonreduced fraction when arguments is a nonreduced fraction:

>>> duration = abjad.Duration(1, 2)
>>> nonreduced_fraction = abjad.NonreducedFraction(3, 6)
>>> duration * nonreduced_fraction
NonreducedFraction(3, 12)

Returns duration or nonreduced fraction.

(Duration).__neg__(*arguments)

Negates duration.

Returns new duration.

static __new__(class_, *arguments, **keywords)

Create and return a new object. See help(type) for accurate signature.

(Duration).__pos__(*arguments)

Get positive duration.

Returns new duration.

(Duration).__pow__(*arguments)

Raises duration to arguments power.

Returns new duration.

(Duration).__radd__(*arguments)

Adds arguments to duration.

Returns new duration.

(Duration).__rdiv__(*arguments)

Divides arguments by duration.

Returns new duration.

(Duration).__rdivmod__(*arguments)

Documentation required.

__repr__()

Gets interpreter representation of offset.

Gets interpreter representation of offset without grace displacement:

>>> abjad.Offset(1, 4)
Offset(1, 4)

Gets interpreter representation of offset with grace displacement:

>>> abjad.Offset(1, 4, grace_displacement=(-1, 16))
Offset(
    (1, 4),
    grace_displacement=Duration(-1, 16)
    )
(Fraction).__rfloordiv__(a)

a // b

(Duration).__rmod__(*arguments)

Documentation required.

(Duration).__rmul__(*arguments)

Multiplies arguments by duration.

Returns new duration.

(Fraction).__round__(ndigits=None)

Will be round(self, ndigits) in 3.0.

Rounds half toward even.

(Duration).__rpow__(*arguments)

Raises arguments to the power of duration.

Returns new duration.

(Duration).__rsub__(*arguments)

Subtracts duration from arguments.

Returns new duration.

(Duration).__rtruediv__(*arguments)

Documentation required.

Returns new duration.

(Fraction).__str__()

str(self)

__sub__(argument)

Offset taken from offset returns duration:

>>> abjad.Offset(2) - abjad.Offset(1, 2)
Duration(3, 2)

Duration taken from offset returns another offset:

>>> abjad.Offset(2) - abjad.Duration(1, 2)
Offset(3, 2)

Coerce argument to offset when argument is neither offset nor duration:

>>> abjad.Offset(2) - abjad.Fraction(1, 2)
Duration(3, 2)

Returns duration or offset.

(Duration).__truediv__(*arguments)

Documentation required.

(Fraction).__trunc__()

trunc(a)


Methods

(Real).conjugate()

Conjugate is a no-op for Reals.

(Fraction).limit_denominator(max_denominator=1000000)

Closest Fraction to self with denominator at most max_denominator.

>>> Fraction('3.141592653589793').limit_denominator(10)
Fraction(22, 7)
>>> Fraction('3.141592653589793').limit_denominator(100)
Fraction(311, 99)
>>> Fraction(4321, 8765).limit_denominator(10000)
Fraction(4321, 8765)
(Duration).to_clock_string()

Changes duration to clock string.

Changes duration to clock string:

>>> note = abjad.Note("c'4")
>>> duration = abjad.Duration(117)
>>> clock_string = duration.to_clock_string()
>>> clock_string
"1'57''"
>>> string = '"{}"'.format(clock_string)
>>> markup = abjad.Markup(string, direction=abjad.Up)
>>> abjad.attach(markup, note)
>>> abjad.show(note) 

Rounds down to nearest second.

Returns string.

(Duration).to_score_markup()

Changes duration to score markup.

Changes assignable duration to score markup:

>>> markup = abjad.Duration(3, 16).to_score_markup()
>>> abjad.show(markup) 

Changes nonassignable duration to score markup:

>>> markup = abjad.Duration(5, 16).to_score_markup()
>>> abjad.show(markup) 

Override tuplet number text like this:

>>> tuplet = abjad.Tuplet((5, 7), "c'16 c' c' c' c' c' c'")
>>> abjad.attach(abjad.Beam(), tuplet[:])
>>> staff = abjad.Staff([tuplet], lilypond_type='RhythmicStaff')
>>> duration = abjad.inspect(tuplet).duration()
>>> markup = duration.to_score_markup()
>>> markup = markup.scale((0.75, 0.75))
>>> abjad.override(tuplet).tuplet_number.text = markup
>>> abjad.show(staff) 

Returns markup.

(Duration).with_denominator(denominator)

Changes duration to nonreduced fraction with denominator.

Changes duration to nonreduced fraction:

>>> duration = abjad.Duration(1, 4)
>>> for denominator in (4, 8, 16, 32):
...     print(duration.with_denominator(denominator))
... 
1/4
2/8
4/16
8/32

Returns new duration.


Class & static methods

static (Duration).durations_to_nonreduced_fractions(durations)

Changes durations to nonreduced fractions sharing least common denominator.

Changes durations to nonreduced fractions:

>>> durations = [abjad.Duration(2, 4), 3, (5, 16)]
>>> result = abjad.Duration.durations_to_nonreduced_fractions(durations)
>>> for x in result:
...     x
... 
NonreducedFraction(8, 16)
NonreducedFraction(48, 16)
NonreducedFraction(5, 16)
Return type:List[NonreducedFraction]
classmethod (Fraction).from_decimal(dec)

Converts a finite Decimal instance to a rational number, exactly.

classmethod (Fraction).from_float(f)

Converts a finite float to a rational number, exactly.

Beware that Fraction.from_float(0.3) != Fraction(3, 10).

static (Duration).from_lilypond_duration_string(lilypond_duration_string)

Initializes duration from LilyPond duration string.

Initializes duration from LilyPond duration string:

>>> abjad.Duration.from_lilypond_duration_string('8.')
Duration(3, 16)

Returns duration.

static (Duration).is_token(argument)

Is true when argument correctly initializes a duration.

Is true when expression is a duration token:

>>> abjad.Duration.is_token('8.')
True

Returns true or false.


Read-only properties

(Fraction).denominator
(Duration).dot_count

Gets dot count.

Gets dot count:

>>> for n in range(1, 16 + 1):
...     try:
...         duration = abjad.Duration(n, 16)
...         sixteenths = duration.with_denominator(16)
...         dot_count = duration.dot_count
...         string = f'{sixteenths!s}\t{dot_count}'
...         print(string)
...     except abjad.AssignabilityError:
...         sixteenths = duration.with_denominator(16)
...         print(f'{sixteenths!s}\t--')
... 
1/16	0
2/16	0
3/16	1
4/16	0
5/16	--
6/16	1
7/16	2
8/16	0
9/16	--
10/16	--
11/16	--
12/16	1
13/16	--
14/16	2
15/16	3
16/16	0

Dot count defined equal to number of dots required to notate duration.

Raises assignability error when duration is not assignable.

Returns positive integer.

(Duration).equal_or_greater_assignable

Gets assignable duration equal to or just greater than this duration.

Gets equal-or-greater assignable duration:

>>> for numerator in range(1, 16 + 1):
...     duration = abjad.Duration(numerator, 16)
...     result = duration.equal_or_greater_assignable
...     sixteenths = duration.with_denominator(16)
...     print(f'{sixteenths!s}\t{result!s}')
... 
1/16	1/16
2/16	1/8
3/16	3/16
4/16	1/4
5/16	3/8
6/16	3/8
7/16	7/16
8/16	1/2
9/16	3/4
10/16	3/4
11/16	3/4
12/16	3/4
13/16	7/8
14/16	7/8
15/16	15/16
16/16	1

Returns new duration.

(Duration).equal_or_greater_power_of_two

Gets duration equal or just greater power of two.

Gets equal-or-greater power-of-two:

>>> for numerator in range(1, 16 + 1):
...     duration = abjad.Duration(numerator, 16)
...     result = duration.equal_or_greater_power_of_two
...     sixteenths = duration.with_denominator(16)
...     print(f'{sixteenths!s}\t{result!s}')
... 
1/16	1/16
2/16	1/8
3/16	1/4
4/16	1/4
5/16	1/2
6/16	1/2
7/16	1/2
8/16	1/2
9/16	1
10/16	1
11/16	1
12/16	1
13/16	1
14/16	1
15/16	1
16/16	1

Returns new duration.

(Duration).equal_or_lesser_assignable

Gets assignable duration equal or just less than this duration.

Gets equal-or-lesser assignable duration:

>>> for numerator in range(1, 16 + 1):
...     duration = abjad.Duration(numerator, 16)
...     result = duration.equal_or_lesser_assignable
...     sixteenths = duration.with_denominator(16)
...     print(f'{sixteenths!s}\t{result!s}')
... 
1/16	1/16
2/16	1/8
3/16	3/16
4/16	1/4
5/16	1/4
6/16	3/8
7/16	7/16
8/16	1/2
9/16	1/2
10/16	1/2
11/16	1/2
12/16	3/4
13/16	3/4
14/16	7/8
15/16	15/16
16/16	1

Returns new duration.

(Duration).equal_or_lesser_power_of_two

Gets duration of the form d**2 equal to or just less than this duration.

Gets equal-or-lesser power-of-two:

>>> for numerator in range(1, 16 + 1):
...     duration = abjad.Duration(numerator, 16)
...     result = duration.equal_or_lesser_power_of_two
...     sixteenths = duration.with_denominator(16)
...     print(f'{sixteenths!s}\t{result!s}')
... 
1/16	1/16
2/16	1/8
3/16	1/8
4/16	1/4
5/16	1/4
6/16	1/4
7/16	1/4
8/16	1/2
9/16	1/2
10/16	1/2
11/16	1/2
12/16	1/2
13/16	1/2
14/16	1/2
15/16	1/2
16/16	1

Returns new duration.

(Duration).flag_count

Gets flag count.

Gets flag count:

>>> for n in range(1, 16 + 1):
...     duration = abjad.Duration(n, 64)
...     sixty_fourths = duration.with_denominator(64)
...     print(f'{sixty_fourths!s}\t{duration.flag_count}')
... 
1/64	4
2/64	3
3/64	3
4/64	2
5/64	2
6/64	2
7/64	2
8/64	1
9/64	1
10/64	1
11/64	1
12/64	1
13/64	1
14/64	1
15/64	1
16/64	0

Flag count defined equal to number of flags required to notate duration.

Returns nonnegative integer.

grace_displacement

Gets grace displacement.

Gets grace displacement equal to none:

>>> offset = abjad.Offset(1, 4)
>>> offset.grace_displacement is None
True

Gets grace displacement equal to a negative sixteenth:

>>> offset = abjad.Offset(1, 4, grace_displacement=(-1, 16))
>>> offset.grace_displacement
Duration(-1, 16)

Stores zero-valued grace displacement as none:

>>> offset = abjad.Offset(1, 4, grace_displacement=0)
>>> offset.grace_displacement is None
True
>>> offset
Offset(1, 4)

Defaults to none.

Set to duration or none.

Returns duration or none.

(Duration).has_power_of_two_denominator

Is true when duration is an integer power of two.

Is true when duration has power-of-two denominator:

>>> for n in range(1, 16 + 1):
...     duration = abjad.Duration(1, n)
...     result = duration.has_power_of_two_denominator
...     print('{!s}\t{}'.format(duration, result))
... 
1	True
1/2	True
1/3	False
1/4	True
1/5	False
1/6	False
1/7	False
1/8	True
1/9	False
1/10	False
1/11	False
1/12	False
1/13	False
1/14	False
1/15	False
1/16	True

Returns true or false.

(Real).imag

Real numbers have no imaginary component.

(Duration).implied_prolation

Gets implied prolation.

Gets implied prolation:

>>> for denominator in range(1, 16 + 1):
...     duration = abjad.Duration(1, denominator)
...     result = duration.implied_prolation
...     print('{!s}\t{!s}'.format(duration, result))
... 
1	1
1/2	1
1/3	2/3
1/4	1
1/5	4/5
1/6	2/3
1/7	4/7
1/8	1
1/9	8/9
1/10	4/5
1/11	8/11
1/12	2/3
1/13	8/13
1/14	4/7
1/15	8/15
1/16	1

Returns multipler.

(Duration).is_assignable

Is true when duration is assignable.

Is true when duration is assignable:

>>> for numerator in range(0, 16 + 1):
...     duration = abjad.Duration(numerator, 16)
...     sixteenths = duration.with_denominator(16)
...     print('{!s}\t{}'.format(sixteenths, duration.is_assignable))
... 
0/16	False
1/16	True
2/16	True
3/16	True
4/16	True
5/16	False
6/16	True
7/16	True
8/16	True
9/16	False
10/16	False
11/16	False
12/16	True
13/16	False
14/16	True
15/16	True
16/16	True

Returns true or false.

(Duration).lilypond_duration_string

Gets LilyPond duration string.

Gets LilyPond duration string:

>>> abjad.Duration(3, 16).lilypond_duration_string
'8.'

Raises assignability error when duration is not assignable.

Returns string.

(Fraction).numerator
(Duration).pair

Gets numerator and denominator.

Gets pair:

>>> abjad.Duration(3, 16).pair
(3, 16)

Returns integer pair.

(Duration).prolation_string

Gets prolation string.

Gets prolation string:

>>> abjad.Duration(3, 16).prolation_string
'16:3'

Returns string.

(Real).real

Real numbers are their real component.

(Duration).reciprocal

Gets reciprocal.

Gets reciprocal:

>>> abjad.Duration(3, 7).reciprocal
Duration(7, 3)

Returns new duration.