WeightedSearchTree

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/abjadext/nauert/../../abjad/system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; } subgraph "cluster_abjadext.nauert" { graph [label="abjadext.nauert"]; node [color=2]; "abjadext.nauert.SearchTree.SearchTree" [URL="../api/abjadext/nauert/SearchTree.html#abjadext.nauert.SearchTree.SearchTree", label="Search\nTree", shape=oval, style=bold, target=_top]; "abjadext.nauert.WeightedSearchTree.WeightedSearchTree" [URL="../api/abjadext/nauert/WeightedSearchTree.html#abjadext.nauert.WeightedSearchTree.WeightedSearchTree", color=black, fontcolor=white, label="Weighted\nSearch\nTree", target=_top]; "abjadext.nauert.SearchTree.SearchTree" -> "abjadext.nauert.WeightedSearchTree.WeightedSearchTree"; } 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]; } "abjad.system.AbjadObject.AbjadObject" -> "abjadext.nauert.SearchTree.SearchTree"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjadext.nauert.WeightedSearchTree.WeightedSearchTree(definition=None)

Weighted search tree.

Allows for dividing nodes in a q-grid into parts with unequal weights.

>>> search_tree = abjadext.nauert.WeightedSearchTree()
>>> abjad.f(search_tree)
abjadext.nauert.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 composition in search_tree.all_compositions:
...     composition
...
(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)

Attributes Summary

all_compositions All compositions of weighted search tree.
default_definition Default definition of weighted search tree.

Special methods

(SearchTree).__call__(q_grid)

Calls search tree.

(SearchTree).__eq__(argument)

Is true when argument 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).__repr__()

Gets interpreter representation of Abjad object.

Returns string.


Read-only properties

all_compositions

All compositions of weighted search tree.

default_definition

Default definition of weighted search tree.

Returns dictionary.

(SearchTree).definition

The search tree definition.

Returns dictionary.