quantizationtools.QGridSearchTree

Inheritance diagram of abjad.tools.quantizationtools.QGridSearchTree.QGridSearchTree.QGridSearchTree

class abjad.tools.quantizationtools.QGridSearchTree.QGridSearchTree.QGridSearchTree(definition=None)[source]

A utility class for defining the permissible divisions of a collection of QGrid objects.

The search tree is defined by a nested dictionary structure, whose keys must be prime integers, and whose values must be None (indicating no further possible divisions) or another dictionary following the same rules.

abjad> from abjad.tools.quantizationtools import QGridSearchTree

For example, In the following tree, the beat may be divided into 2 or into 5. If divided into 2, it may be divided again into 2 or into 3.

abjad> search_tree = QGridSearchTree({2: {2: None, 3: None}, 5: None})

Return a new QGridSearchTree.

Read-only Properties

QGridSearchTree.offsets[source]

An ordered tuple of all Offset objects which those QGrid objects governed by a specific QGridSearchTree can contain.

abjad> from abjad.tools.quantizationtools import QGridSearchTree
abjad> qst = QGridSearchTree({2: {3: None}})
abjad> qst.offsets
(Offset(0, 1), Offset(1, 6), Offset(1, 3), Offset(1, 2), Offset(2, 3), Offset(5, 6), Offset(1, 1))

Returns a tuple.

Methods

QGridSearchTree.clear() → None. Remove all items from D.

Note

Inherited from __builtin__.dict

QGridSearchTree.copy() → a shallow copy of D

Note

Inherited from __builtin__.dict

QGridSearchTree.find_subtree_divisibility(parentage)[source]

Given a parentage signature, defining some subtree of a QGridSearchTree, return a tuple of permitted divisions of that subtree.

abjad> from abjad.tools.quantizationtools import QGridSearchTree
abjad> qst = QGridSearchTree({2: {2: None, 3: {7: None, 11: None}}, 5: None})
abjad> qst.find_subtree_divisibility((2,))
(2, 3)
abjad> qst.find_subtree_divisibility((2, 2))
()
abjad> qst.find_subtree_divisibility((2, 3))
(7, 11)
abjad> qst.find_subtree_divisibility((2, 3, 7))
()

Returns a tuple.

QGridSearchTree.get(k[, d]) → D[k] if k in D, else d. d defaults to None.

Note

Inherited from __builtin__.dict

QGridSearchTree.has_key(k) → True if D has a key k, else False

Note

Inherited from __builtin__.dict

QGridSearchTree.items() → list of D's (key, value) pairs, as 2-tuples

Note

Inherited from __builtin__.dict

QGridSearchTree.iteritems() → an iterator over the (key, value) items of D

Note

Inherited from __builtin__.dict

QGridSearchTree.iterkeys() → an iterator over the keys of D

Note

Inherited from __builtin__.dict

QGridSearchTree.itervalues() → an iterator over the values of D

Note

Inherited from __builtin__.dict

QGridSearchTree.keys() → list of D's keys

Note

Inherited from __builtin__.dict

QGridSearchTree.pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

Note

Inherited from __builtin__.dict

QGridSearchTree.popitem() → (k, v), remove and return some (key, value) pair as a

2-tuple; but raise KeyError if D is empty.

Note

Inherited from __builtin__.dict

QGridSearchTree.prune(beatspan, tempo, threshold)[source]

Prune those subtrees of a QGridSearchTree whose divisions in milliseconds, given beatspan and tempo, would be less than threshold.

This allows a composer to specify the maximum speed any quantization operation will permit.

abjad> from abjad.tools.quantizationtools import QGridSearchTree
abjad> qst = QGridSearchTree({2: {2: {2: {2: None}}}})
abjad> beatspan = Fraction(1, 4)
abjad> tempo = contexttools.TempoMark((1, 4), 60)
abjad> qst.prune(beatspan, tempo, 100)
{2: {2: {2: None}}}
abjad> qst.prune(beatspan, tempo, 200)
{2: {2: None}}
abjad> qst.prune(beatspan, tempo, 400)
{2: None}

Returns a new QGridSearchTree.

QGridSearchTree.setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D

Note

Inherited from __builtin__.dict

QGridSearchTree.update(E, **F) → None. Update D from dict/iterable E and F.

If E has a .keys() method, does: for k in E: D[k] = E[k] If E lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

Note

Inherited from __builtin__.dict

QGridSearchTree.values() → list of D's values

Note

Inherited from __builtin__.dict

QGridSearchTree.viewitems() → a set-like object providing a view on D's items

Note

Inherited from __builtin__.dict

QGridSearchTree.viewkeys() → a set-like object providing a view on D's keys

Note

Inherited from __builtin__.dict

QGridSearchTree.viewvalues() → an object providing a view on D's values

Note

Inherited from __builtin__.dict

Special Methods

QGridSearchTree.__cmp__(y) <==> cmp(x, y)

Note

Inherited from __builtin__.dict

QGridSearchTree.__contains__(k) → True if D has a key k, else False

Note

Inherited from __builtin__.dict

QGridSearchTree.__delattr__()

x.__delattr__(‘name’) <==> del x.name

Note

Inherited from __builtin__.object

QGridSearchTree.__delitem__(*args)
QGridSearchTree.__eq__()

x.__eq__(y) <==> x==y

Note

Inherited from __builtin__.dict

QGridSearchTree.__ge__()

x.__ge__(y) <==> x>=y

Note

Inherited from __builtin__.dict

QGridSearchTree.__getitem__()

x.__getitem__(y) <==> x[y]

Note

Inherited from __builtin__.dict

QGridSearchTree.__gt__()

x.__gt__(y) <==> x>y

Note

Inherited from __builtin__.dict

QGridSearchTree.__iter__() <==> iter(x)

Note

Inherited from __builtin__.dict

QGridSearchTree.__le__()

x.__le__(y) <==> x<=y

Note

Inherited from __builtin__.dict

QGridSearchTree.__len__() <==> len(x)

Note

Inherited from __builtin__.dict

QGridSearchTree.__lt__()

x.__lt__(y) <==> x<y

Note

Inherited from __builtin__.dict

QGridSearchTree.__ne__()

x.__ne__(y) <==> x!=y

Note

Inherited from __builtin__.dict

QGridSearchTree.__repr__() <==> repr(x)

Note

Inherited from __builtin__.dict

QGridSearchTree.__setattr__()

x.__setattr__(‘name’, value) <==> x.name = value

Note

Inherited from __builtin__.object

QGridSearchTree.__setitem__(*args)
QGridSearchTree.__str__() <==> str(x)

Note

Inherited from __builtin__.object

Table Of Contents

This Page