WeightedSearchTree

class quantizationtools.WeightedSearchTree(definition=None)

A search tree that allows for dividing nodes in a QGrid into parts with unequal weights:

>>> search_tree = quantizationtools.WeightedSearchTree()
>>> print(format(search_tree))
quantizationtools.WeightedSearchTree(
    definition={
        'divisors': (2, 3, 5, 7),
        'max_depth': 3,
        'max_divisions': 2,
        },
    )

In WeightedSearchTree‘s definition:

  • divisors controls the sum of the parts of the ratio a node may be divided into,
  • max_depth controls how many levels of tuplet nesting are permitted, and
  • max_divisions controls the maximum permitted length of the weights in the ratio.

Thus, the default WeightedSearchTree permits the following ratios:

>>> for x in search_tree.all_compositions:
...     x
...
(1, 1)
(2, 1)
(1, 2)
(4, 1)
(3, 2)
(2, 3)
(1, 4)
(6, 1)
(5, 2)
(4, 3)
(3, 4)
(2, 5)
(1, 6)

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

Bases

Attribute summary

all_compositions All compositions of weighted search tree.
default_definition Default definition of weighted search tree.
definition The search tree definition.
__call__(q_grid) Calls search tree.
__eq__(expr) Is true when expr is a search tree with definition equal to that of this search tree.
__format__([format_specification]) Formats Abjad object.
__hash__() Hashes search tree.
__ne__(expr) Is true when Abjad object does not equal expr.
__repr__() Gets interpreter representation of Abjad object.

Read-only properties

WeightedSearchTree.all_compositions

All compositions of weighted search tree.

WeightedSearchTree.default_definition

Default definition of weighted search tree.

Returns dictionary.

(SearchTree).definition

The search tree definition.

Returns dictionary.

Special methods

(SearchTree).__call__(q_grid)

Calls search tree.

(SearchTree).__eq__(expr)

Is true when expr is a search tree with definition equal to that of this search tree. 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.

(SearchTree).__hash__()

Hashes search tree.

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.