QGridLeaf

class quantizationtools.QGridLeaf(preprolated_duration=1, q_event_proxies=None, is_divisible=True)

A leaf in a QGrid structure.

>>> leaf = quantizationtools.QGridLeaf()
>>> leaf
QGridLeaf(
    preprolated_duration=Duration(1, 1),
    is_divisible=True
    )

Used internally by QGrid.

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_datastructuretools { graph [label=datastructuretools]; "abjad.tools.datastructuretools.TreeNode.TreeNode" [color=3, group=2, label=TreeNode, shape=box]; } subgraph cluster_quantizationtools { graph [label=quantizationtools]; "abjad.tools.quantizationtools.QGridLeaf.QGridLeaf" [color=black, fontcolor=white, group=3, label=<<B>QGridLeaf</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_rhythmtreetools { graph [label=rhythmtreetools]; "abjad.tools.rhythmtreetools.RhythmTreeMixin.RhythmTreeMixin" [color=5, group=4, label=RhythmTreeMixin, shape=oval, style=bold]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.datastructuretools.TreeNode.TreeNode"; "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.rhythmtreetools.RhythmTreeMixin.RhythmTreeMixin"; "abjad.tools.datastructuretools.TreeNode.TreeNode" -> "abjad.tools.quantizationtools.QGridLeaf.QGridLeaf"; "abjad.tools.rhythmtreetools.RhythmTreeMixin.RhythmTreeMixin" -> "abjad.tools.quantizationtools.QGridLeaf.QGridLeaf"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Attribute summary

depth The depth of a node in a rhythm-tree structure.
depthwise_inventory A dictionary of all nodes in a rhythm-tree, organized by their depth relative the root node.
duration The preprolated_duration of the node:
graph_order Graph order of tree node.
improper_parentage The improper parentage of a node in a rhythm-tree, being the sequence of node beginning with itself and ending with the root node of the tree.
is_divisible Flag for whether the node may be further divided under some search tree.
name Named of tree node.
parent Parent of tree node.
parentage_ratios A sequence describing the relative durations of the nodes in a node’s improper parentage.
preceding_q_event_proxies Preceding q-event proxies of q-grid leaf.
preprolated_duration The node’s preprolated_duration in pulses:
pretty_rtm_format The node’s pretty-printed RTM format:
prolation Prolation of rhythm tree node.
prolations Prolations of rhythm tree node.
proper_parentage The proper parentage of a node in a rhythm-tree, being the sequence of node beginning with the node’s immediate parent and ending with the root node of the tree.
q_event_proxies Q-event proxies of q-grid leaf.
root The root node of the tree: that node in the tree which has no parent.
rtm_format RTM format of q-grid leaf.
start_offset The starting offset of a node in a rhythm-tree relative the root.
stop_offset The stopping offset of a node in a rhythm-tree relative the root.
succeeding_q_event_proxies Succeeding q-event proxies of q-grid leaf.
__call__(pulse_duration) Calls q-grid leaf.
__copy__() Copies tree node.
__eq__(expr) Is true when ID of expr equals ID of Abjad object.
__format__([format_specification]) Formats Abjad object.
__graph__(\*\*kwargs) Graphviz graph of q-grid leaf.
__hash__() Hashes Abjad object.
__ne__(expr) Is true when Abjad object does not equal expr.
__repr__() Gets interpreter representation of Abjad object.

Read-only properties

(TreeNode).depth

The depth of a node in a rhythm-tree structure.

>>> a = datastructuretools.TreeContainer()
>>> b = datastructuretools.TreeContainer()
>>> c = datastructuretools.TreeNode()
>>> a.append(b)
>>> b.append(c)
>>> a.depth
0
>>> a[0].depth
1
>>> a[0][0].depth
2

Returns int.

(TreeNode).depthwise_inventory

A dictionary of all nodes in a rhythm-tree, organized by their depth relative the root node.

>>> a = datastructuretools.TreeContainer(name='a')
>>> b = datastructuretools.TreeContainer(name='b')
>>> c = datastructuretools.TreeContainer(name='c')
>>> d = datastructuretools.TreeContainer(name='d')
>>> e = datastructuretools.TreeContainer(name='e')
>>> f = datastructuretools.TreeContainer(name='f')
>>> g = datastructuretools.TreeContainer(name='g')
>>> a.extend([b, c])
>>> b.extend([d, e])
>>> c.extend([f, g])
>>> inventory = a.depthwise_inventory
>>> for depth in sorted(inventory):
...     print('DEPTH: {}'.format(depth))
...     for node in inventory[depth]:
...         print(node.name)
...
DEPTH: 0
a
DEPTH: 1
b
c
DEPTH: 2
d
e
f
g

Returns dictionary.

(RhythmTreeMixin).duration

The preprolated_duration of the node:

>>> rtm = '(1 ((1 (1 1)) (1 (1 1))))'
>>> tree = rhythmtreetools.RhythmTreeParser()(rtm)[0]
>>> tree.duration
Duration(1, 1)
>>> tree[1].duration
Duration(1, 2)
>>> tree[1][1].duration
Duration(1, 4)

Return Duration instance.

(TreeNode).graph_order

Graph order of tree node.

Returns tuple.

(TreeNode).improper_parentage

The improper parentage of a node in a rhythm-tree, being the sequence of node beginning with itself and ending with the root node of the tree.

>>> a = datastructuretools.TreeContainer()
>>> b = datastructuretools.TreeContainer()
>>> c = datastructuretools.TreeNode()
>>> a.append(b)
>>> b.append(c)
>>> a.improper_parentage == (a,)
True
>>> b.improper_parentage == (b, a)
True
>>> c.improper_parentage == (c, b, a)
True

Returns tuple of tree nodes.

(TreeNode).parent

Parent of tree node.

>>> a = datastructuretools.TreeContainer()
>>> b = datastructuretools.TreeContainer()
>>> c = datastructuretools.TreeNode()
>>> a.append(b)
>>> b.append(c)
>>> a.parent is None
True
>>> b.parent is a
True
>>> c.parent is b
True

Returns tree node.

(RhythmTreeMixin).parentage_ratios

A sequence describing the relative durations of the nodes in a node’s improper parentage.

The first item in the sequence is the preprolated_duration of the root node, and subsequent items are pairs of the preprolated duration of the next node in the parentage and the total preprolated_duration of that node and its siblings:

>>> a = rhythmtreetools.RhythmTreeContainer(preprolated_duration=1)
>>> b = rhythmtreetools.RhythmTreeContainer(preprolated_duration=2)
>>> c = rhythmtreetools.RhythmTreeLeaf(preprolated_duration=3)
>>> d = rhythmtreetools.RhythmTreeLeaf(preprolated_duration=4)
>>> e = rhythmtreetools.RhythmTreeLeaf(preprolated_duration=5)
>>> a.extend([b, c])
>>> b.extend([d, e])
>>> a.parentage_ratios
(Duration(1, 1),)
>>> b.parentage_ratios
(Duration(1, 1), (Duration(2, 1), Duration(5, 1)))
>>> c.parentage_ratios
(Duration(1, 1), (Duration(3, 1), Duration(5, 1)))
>>> d.parentage_ratios
(Duration(1, 1), (Duration(2, 1), Duration(5, 1)), (Duration(4, 1), Duration(9, 1)))
>>> e.parentage_ratios
(Duration(1, 1), (Duration(2, 1), Duration(5, 1)), (Duration(5, 1), Duration(9, 1)))

Returns tuple.

QGridLeaf.preceding_q_event_proxies

Preceding q-event proxies of q-grid leaf.

Returns list.

(RhythmTreeMixin).pretty_rtm_format

The node’s pretty-printed RTM format:

>>> rtm = '(1 ((1 (1 1)) (1 (1 1))))'
>>> tree = rhythmtreetools.RhythmTreeParser()(rtm)[0]
>>> print(tree.pretty_rtm_format)
(1 (
    (1 (
        1
        1))
    (1 (
        1
        1))))

Returns string.

(RhythmTreeMixin).prolation

Prolation of rhythm tree node.

Returns multiplier.

(RhythmTreeMixin).prolations

Prolations of rhythm tree node.

Returns tuple.

(TreeNode).proper_parentage

The proper parentage of a node in a rhythm-tree, being the sequence of node beginning with the node’s immediate parent and ending with the root node of the tree.

>>> a = datastructuretools.TreeContainer()
>>> b = datastructuretools.TreeContainer()
>>> c = datastructuretools.TreeNode()
>>> a.append(b)
>>> b.append(c)
>>> a.proper_parentage == ()
True
>>> b.proper_parentage == (a,)
True
>>> c.proper_parentage == (b, a)
True

Returns tuple of tree nodes.

QGridLeaf.q_event_proxies

Q-event proxies of q-grid leaf.

(TreeNode).root

The root node of the tree: that node in the tree which has no parent.

>>> a = datastructuretools.TreeContainer()
>>> b = datastructuretools.TreeContainer()
>>> c = datastructuretools.TreeNode()
>>> a.append(b)
>>> b.append(c)
>>> a.root is a
True
>>> b.root is a
True
>>> c.root is a
True

Returns tree node.

QGridLeaf.rtm_format

RTM format of q-grid leaf.

(RhythmTreeMixin).start_offset

The starting offset of a node in a rhythm-tree relative the root.

>>> rtm = '(1 ((1 (1 1)) (1 (1 1))))'
>>> tree = rhythmtreetools.RhythmTreeParser()(rtm)[0]
>>> tree.start_offset
Offset(0, 1)
>>> tree[1].start_offset
Offset(1, 2)
>>> tree[0][1].start_offset
Offset(1, 4)

Returns Offset instance.

(RhythmTreeMixin).stop_offset

The stopping offset of a node in a rhythm-tree relative the root.

QGridLeaf.succeeding_q_event_proxies

Succeeding q-event proxies of q-grid leaf.

Returns list.

Read/write properties

QGridLeaf.is_divisible

Flag for whether the node may be further divided under some search tree.

(TreeNode).name

Named of tree node.

Returns string.

(RhythmTreeMixin).preprolated_duration

The node’s preprolated_duration in pulses:

>>> node = rhythmtreetools.RhythmTreeLeaf(
...     preprolated_duration=1)
>>> node.preprolated_duration
Duration(1, 1)
>>> node.preprolated_duration = 2
>>> node.preprolated_duration
Duration(2, 1)

Returns int.

Special methods

QGridLeaf.__call__(pulse_duration)

Calls q-grid leaf.

Returns selection of notes.

(TreeNode).__copy__()

Copies tree node.

(AbjadObject).__eq__(expr)

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

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

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

Returns string.

QGridLeaf.__graph__(**kwargs)

Graphviz graph of q-grid leaf.

Returns Graphviz graph.

(AbjadObject).__hash__()

Hashes Abjad object.

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

Returns integer.

(AbjadObject).__ne__(expr)

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

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.