Abjad model of a QGrid, a nesting division structure which assists certain quantization algorithms.
QGrids are defined by a list, which must be prime in length, whose members are either Numbers or tuples of Numbers (useful for representing timepoint or pitch information), a QEvent or tuple of QEvent objects, or None (representing silence), or other lists which must recursively obey the same rules.
QGrids also have a next attribute, representing the downbeat of not “this” QGrid, but the next QGrid in a list of grids. This is useful as timepoints must often be quantized not to any internal division of a the “current” beat, but to the next beat.
abjad> from abjad.tools.quantizationtools import QGrid
abjad> q = QGrid([0, 0, [0, 0]], 0)
The values in the grid can be access via subscript, as though the grid were a flat list.
abjad> q[0] = 1
abjad> q[2] = 3
abjad> q[4] = 5
abjad> q
QGrid([1, 0, [3, 0]], 5)
QGrids are quasi-immutable.
The nested list which defines the QGrid’s structure.
abjad> from abjad.tools.quantizationtools import QGrid
abjad> q = QGrid([0, 0, [0, 0]], 0)
abjad> q.definition
[0, 0, [0, 0]]
Read-only.
The contents of the final offset in the QGrid.
abjad> from abjad.tools.quantizationtools import QGrid
abjad> q = QGrid([0, 0, [0, 0]], 0)
abjad> q[-1] = 9
abjad> q
QGrid([0, 0, [0, 0]], 9)
abjad> q.next
9
Read-only.
An ordered tuple of those Offset objects generated by the division structure of a QGrid.
abjad> from abjad.tools.quantizationtools import QGrid
abjad> q = QGrid([0, [0, 0], 0], 0)
abjad> q.offsets
(Offset(0, 1), Offset(1, 3), Offset(1, 2), Offset(2, 3), Offset(1, 1))
Read-only.
Given a list of numbers 0 <= n <= 1, return a list of indices in self which countain those points, as though they were segments.
abjad> from abjad.tools.quantizationtools import QGrid
abjad> q = QGrid([0, [0, 0]], 0)
abjad> q.offsets
(Offset(0, 1), Offset(1, 2), Offset(3, 4), Offset(1, 1))
abjad> points = [0.1, 0.9]
abjad> q.find_divisible_indices(points)
[0, 2]
Returns a list.
Return a tuple of the lengths of each container containing index, from the topmost to the bottommost.
abjad> from abjad.tools.quantizationtools import QGrid
abjad> q = QGrid([0, [0, [0, 0], 0], 0, 0, 0], 0)
abjad> q.find_parentage_of_index(0)
(5,)
abjad> q.find_parentage_of_index(1)
(5, 3)
abjad> q.find_parentage_of_index(2)
(5, 3, 2)
abjad> q.find_parentage_of_index(7)
(5,)
Returns a tuple.
Return an Abjad container, whose structure mirrors the division structure of the QGrid. The values of the items in the QGrid have no effect on the output.
abjad> from abjad.tools.quantizationtools import QGrid
abjad> q = QGrid([0, [0, 0], 0], 0)
abjad> q.format_for_beatspan()
Tuplet(2/3, [c'8, c'16, c'16, c'8])
Returns a Tuplet or Container, depending on structure.
Given a list of 2-tuples, where for each tuple t, t[0] is a valid index into self, and t[1] is a prime integer greater than 1, return a new QGrid with those indices subdivided.
abjad> from abjad.tools.quantizationtools import QGrid
abjad> q = QGrid([0, 0], 0)
abjad> q.subdivide_indices([(0, 2), (1, 3)])
QGrid([[0, 0], [0, 0, 0]], 0)
Returns a new QGrid.
x.__delattr__(‘name’) <==> del x.name
Note
Inherited from __builtin__.object
Abjad objects by default do not implement this method.
Raise exception.
Note
Inherited from abctools.AbjadObject
Abjad objects by default do not implement this method.
Raise exception
Note
Inherited from abctools.AbjadObject
Note
Inherited from __builtin__.object
Abjad objects by default do not implement this method.
Raise exception.
Note
Inherited from abctools.AbjadObject
Abjad objects by default do not implement this method.
Raise exception.
Note
Inherited from abctools.AbjadObject
True when id(self) does not equal id(arg).
Return boolean.
Note
Inherited from abctools.AbjadObject
x.__setattr__(‘name’, value) <==> x.name = value
Note
Inherited from __builtin__.object
Note
Inherited from __builtin__.object