PartitionTable

class rhythmmakertools.PartitionTable(items=None, item_class=None)

Partition table.

Example 1. Partitions integers roughly 1:1 (restricted to assignable values) with larger half on left:

>>> table = rhythmmakertools.PartitionTable([
...     (2, [1, 1]),
...     (3, [2, 1]),
...     (5, [3, 2]),
...     (7, [4, 3]),
...     ])
>>> print(format(table))
abjad.rhythmmakertools.PartitionTable(
    [
        (
            2,
            mathtools.NonreducedRatio((1, 1)),
            ),
        (
            3,
            mathtools.NonreducedRatio((2, 1)),
            ),
        (
            5,
            mathtools.NonreducedRatio((3, 2)),
            ),
        (
            7,
            mathtools.NonreducedRatio((4, 3)),
            ),
        ]
    )

Example 2. Partitions integers roughly 1:1 (restricted to assignable values) with larger half on right:

>>> table = rhythmmakertools.PartitionTable([
...     (2, [1, 1]),
...     (3, [1, 2]),
...     (5, [2, 3]),
...     (7, [3, 4]),
...     ])
>>> print(format(table))
abjad.rhythmmakertools.PartitionTable(
    [
        (
            2,
            mathtools.NonreducedRatio((1, 1)),
            ),
        (
            3,
            mathtools.NonreducedRatio((1, 2)),
            ),
        (
            5,
            mathtools.NonreducedRatio((2, 3)),
            ),
        (
            7,
            mathtools.NonreducedRatio((3, 4)),
            ),
        ]
    )

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

Attribute summary

clear() Clears typed ordered dictionary.
copy() Copies typed ordered dictionary.
get(i[, default]) Aliases OrderedDict.get().
has_key(key) Aliases OrderdDict.has_key().
item_class Item class to coerce items into.
items() Aliases OrderedDict.items().
keys() Aliases OrderedDict.keys().
pop(key[, default]) Aliases OrderedDict.pop().
popitem() Aliases OrderedDict.popitem().
respell_division(division) Respells division according to partition table.
setdefault(key[, default]) Aliases OrderedDict.setdefault().
update(\*args, \*\*kwargs) Aliases OrderedDict.update().
values() Aliases OrderedDict.values().
__cmp__(expr) Aliases OrderedDict.__cmp__().
__contains__(key) Aliases OrderedDict.__contains__().
__delitem__(i) Aliases OrderedDict.__delitem__().
__eq__(expr) Is true when expr is a typed collection with items that compare equal to those of this typed collection.
__format__([format_specification]) Formats Abjad object.
__ge__(expr) Is true when typed ordered dictionary is greater than or equal to expr.
__getitem__(i) Aliases OrderedDict.__getitem__().
__gt__(expr) Is true when typed ordered dictionary is greater than expr.
__hash__() Hashes typed collection.
__iter__() Iterates typed collection.
__le__(expr) Is true when typed ordered dictionary is less than or equal to expr.
__len__() Length of typed collection.
__lt__(expr) Is true when typed ordered dictionary is less than expr.
__ne__(expr) Is true when typed ordered dictionary is not equal to expr.
__repr__() Gets interpreter representation of Abjad object.
__reversed__() Aliases OrderedDict.__reversed__().
__setitem__(i, expr) Changes items in expr to items and sets.

Read-only properties

(TypedCollection).item_class

Item class to coerce items into.

Methods

(TypedOrderedDict).clear()

Clears typed ordered dictionary.

Returns none.

(TypedOrderedDict).copy()

Copies typed ordered dictionary.

Returns new typed ordered dictionary.

(TypedOrderedDict).get(i, default=None)

Aliases OrderedDict.get().

Returns item or raises key error.

(TypedOrderedDict).has_key(key)

Aliases OrderdDict.has_key().

Returns true or false.

(TypedOrderedDict).items()

Aliases OrderedDict.items().

Returns generator.

(TypedOrderedDict).keys()

Aliases OrderedDict.keys().

Returns generator.

(TypedOrderedDict).pop(key, default=None)

Aliases OrderedDict.pop().

Returns items.

(TypedOrderedDict).popitem()

Aliases OrderedDict.popitem().

Returns generator.

PartitionTable.respell_division(division)

Respells division according to partition table.

Example 1. Respells divisions according to table:

>>> table = rhythmmakertools.PartitionTable([
...     (2, [1, 1]),
...     (3, [2, 1]),
...     (5, [3, 2]),
...     (7, [4, 3]),
...     ])
>>> for numerator in range(1, 15):
...     division = mathtools.NonreducedFraction(numerator, 4)
...     result = table.respell_division(division)
...     print((division, result))
...
(NonreducedFraction(1, 4), [NonreducedFraction(1, 4)])
(NonreducedFraction(2, 4), [NonreducedFraction(1, 4), NonreducedFraction(1, 4)])
(NonreducedFraction(3, 4), [NonreducedFraction(2, 4), NonreducedFraction(1, 4)])
(NonreducedFraction(4, 4), [NonreducedFraction(2, 4), NonreducedFraction(2, 4)])
(NonreducedFraction(5, 4), [NonreducedFraction(3, 4), NonreducedFraction(2, 4)])
(NonreducedFraction(6, 4), [NonreducedFraction(4, 4), NonreducedFraction(2, 4)])
(NonreducedFraction(7, 4), [NonreducedFraction(4, 4), NonreducedFraction(3, 4)])
(NonreducedFraction(8, 4), [NonreducedFraction(4, 4), NonreducedFraction(4, 4)])
(NonreducedFraction(9, 4), [NonreducedFraction(6, 4), NonreducedFraction(3, 4)])
(NonreducedFraction(10, 4), [NonreducedFraction(6, 4), NonreducedFraction(4, 4)])
(NonreducedFraction(11, 4), [NonreducedFraction(11, 4)])
(NonreducedFraction(12, 4), [NonreducedFraction(8, 4), NonreducedFraction(4, 4)])
(NonreducedFraction(13, 4), [NonreducedFraction(13, 4)])
(NonreducedFraction(14, 4), [NonreducedFraction(8, 4), NonreducedFraction(6, 4)])

Example 2. Respells divisions according to another table:

>>> table = rhythmmakertools.PartitionTable([
...     (5, [1, 3, 1]),
...     (7, [1, 2, 4]),
...     ])
>>> for numerator in range(1, 15):
...     division = mathtools.NonreducedFraction(numerator, 4)
...     result = table.respell_division(division)
...     print((division, result))
...
(NonreducedFraction(1, 4), [NonreducedFraction(1, 4)])
(NonreducedFraction(2, 4), [NonreducedFraction(2, 4)])
(NonreducedFraction(3, 4), [NonreducedFraction(3, 4)])
(NonreducedFraction(4, 4), [NonreducedFraction(4, 4)])
(NonreducedFraction(5, 4), [NonreducedFraction(1, 4), NonreducedFraction(3, 4), NonreducedFraction(1, 4)])
(NonreducedFraction(6, 4), [NonreducedFraction(6, 4)])
(NonreducedFraction(7, 4), [NonreducedFraction(1, 4), NonreducedFraction(2, 4), NonreducedFraction(4, 4)])
(NonreducedFraction(8, 4), [NonreducedFraction(8, 4)])
(NonreducedFraction(9, 4), [NonreducedFraction(9, 4)])
(NonreducedFraction(10, 4), [NonreducedFraction(2, 4), NonreducedFraction(6, 4), NonreducedFraction(2, 4)])
(NonreducedFraction(11, 4), [NonreducedFraction(11, 4)])
(NonreducedFraction(12, 4), [NonreducedFraction(12, 4)])
(NonreducedFraction(13, 4), [NonreducedFraction(13, 4)])
(NonreducedFraction(14, 4), [NonreducedFraction(2, 4), NonreducedFraction(4, 4), NonreducedFraction(8, 4)])

Returns list of new divisions.

(TypedOrderedDict).setdefault(key, default=None)

Aliases OrderedDict.setdefault().

Returns items.

(TypedOrderedDict).update(*args, **kwargs)

Aliases OrderedDict.update().

Returns none.

(TypedOrderedDict).values()

Aliases OrderedDict.values().

Returns generator.

Special methods

(TypedOrderedDict).__cmp__(expr)

Aliases OrderedDict.__cmp__().

Returns true or false.

(TypedOrderedDict).__contains__(key)

Aliases OrderedDict.__contains__().

Returns true or false.

(TypedOrderedDict).__delitem__(i)

Aliases OrderedDict.__delitem__().

Returns none.

(TypedCollection).__eq__(expr)

Is true when expr is a typed collection with items that compare equal to those of this typed collection. 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.

(TypedOrderedDict).__ge__(expr)

Is true when typed ordered dictionary is greater than or equal to expr. Otherwise false.

Returns true or false.

(TypedOrderedDict).__getitem__(i)

Aliases OrderedDict.__getitem__().

Returns item.

(TypedOrderedDict).__gt__(expr)

Is true when typed ordered dictionary is greater than expr. Otherwise false.

Returns true or false.

(TypedCollection).__hash__()

Hashes typed collection.

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

Returns integer.

(TypedCollection).__iter__()

Iterates typed collection.

Returns generator.

(TypedOrderedDict).__le__(expr)

Is true when typed ordered dictionary is less than or equal to expr. Otherwise false.

Returns true or false.

(TypedCollection).__len__()

Length of typed collection.

Returns nonnegative integer.

(TypedOrderedDict).__lt__(expr)

Is true when typed ordered dictionary is less than expr. Otherwise false.

Returns true or false.

(TypedOrderedDict).__ne__(expr)

Is true when typed ordered dictionary is not equal to expr. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

(TypedOrderedDict).__reversed__()

Aliases OrderedDict.__reversed__().

Returns generatos.

(TypedOrderedDict).__setitem__(i, expr)

Changes items in expr to items and sets.

Returns none.