RhythmTreeContainer

class rhythmtreetools.RhythmTreeContainer(children=None, preprolated_duration=1, name=None)

A rhythm-tree container.

Example 1. Initializes a rhythm-tree container:

>>> container = rhythmtreetools.RhythmTreeContainer(
...     preprolated_duration=1, children=[])
>>> print(format(container))
rhythmtreetools.RhythmTreeContainer(
    preprolated_duration=durationtools.Duration(1, 1),
    )

Example 2. Similar to Abjad containers, RhythmTreeContainer supports a list interface, and can be appended, extended, indexed and so forth by other RhythmTreeMixin subclasses:

>>> leaf_a = rhythmtreetools.RhythmTreeLeaf(preprolated_duration=1)
>>> leaf_b = rhythmtreetools.RhythmTreeLeaf(preprolated_duration=2)
>>> container.extend([leaf_a, leaf_b])
>>> print(format(container))
rhythmtreetools.RhythmTreeContainer(
    children=(
        rhythmtreetools.RhythmTreeLeaf(
            preprolated_duration=durationtools.Duration(1, 1),
            is_pitched=True,
            ),
        rhythmtreetools.RhythmTreeLeaf(
            preprolated_duration=durationtools.Duration(2, 1),
            is_pitched=True,
            ),
        ),
    preprolated_duration=durationtools.Duration(1, 1),
    )
>>> another_container = rhythmtreetools.RhythmTreeContainer(
...     preprolated_duration=2)
>>> another_container.append(
...     rhythmtreetools.RhythmTreeLeaf(preprolated_duration=3))
>>> another_container.append(container[1])
>>> container.append(another_container)
>>> print(format(container))
rhythmtreetools.RhythmTreeContainer(
    children=(
        rhythmtreetools.RhythmTreeLeaf(
            preprolated_duration=durationtools.Duration(1, 1),
            is_pitched=True,
            ),
        rhythmtreetools.RhythmTreeContainer(
            children=(
                rhythmtreetools.RhythmTreeLeaf(
                    preprolated_duration=durationtools.Duration(3, 1),
                    is_pitched=True,
                    ),
                rhythmtreetools.RhythmTreeLeaf(
                    preprolated_duration=durationtools.Duration(2, 1),
                    is_pitched=True,
                    ),
                ),
            preprolated_duration=durationtools.Duration(2, 1),
            ),
        ),
    preprolated_duration=durationtools.Duration(1, 1),
    )

Example 3. Call RhythmTreeContainer with a preprolated_duration to generate a tuplet structure:

>>> list_ = container((1, 4))
>>> list_
[FixedDurationTuplet(Duration(1, 4), "c'8 { 4/5 c'8. c'8 }")]
>>> tuplet = list_[0]
>>> show(tuplet) 

Returns RhythmTreeContainer instance.

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

Attribute summary

append(node) Appends node to tree container.
children Children of tree container.
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:
extend(argument) Extendes argument against tree container.
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.
index(node) Indexes node in tree container.
insert(i, node) Insert node in tree container at index i.
leaves Leaves of tree container.
name Named of tree node.
nodes The collection of tree nodes produced by iterating tree container depth-first.
parent Parent of tree node.
parentage_ratios A sequence describing the relative durations of the nodes in a node’s improper parentage.
pop([i]) Pops node i from tree container.
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.
remove(node) Remove node from tree container.
root The root node of the tree: that node in the tree which has no parent.
rtm_format The node’s RTM format:
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.
__add__(argument) Concatenate containers self and argument.
__call__(pulse_duration) Generate Abjad score components:
__contains__(argument) True if argument is in container.
__copy__() Copies tree node.
__delitem__(i) Deletes node i in tree container.
__eq__(argument) Is true when ID of argument equals ID of Abjad object.
__format__([format_specification]) Formats Abjad object.
__getitem__(argument) Gets item or slice identified by argument.
__graph__(**keywords) The GraphvizGraph representation of the RhythmTreeContainer:
__hash__() Hashes Abjad object.
__iter__() Iterates tree container.
__len__() Returns nonnegative integer number of nodes in container.
__ne__(argument) Is true when Abjad object does not equal argument.
__repr__() Gets interpreter representation of rhythm tree container.
__setitem__(i, argument) Set argument in self at nonnegative integer index i, or set argument in self at slice i.

Read-only properties

(TreeContainer).children

Children of tree container.

>>> a = datastructuretools.TreeContainer()
>>> b = datastructuretools.TreeContainer()
>>> c = datastructuretools.TreeNode()
>>> d = datastructuretools.TreeNode()
>>> e = datastructuretools.TreeContainer()
>>> a.extend([b, c])
>>> b.extend([d, e])
>>> a.children == (b, c)
True
>>> b.children == (d, e)
True
>>> e.children == ()
True

Returns tuple of tree nodes.

(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.

(TreeContainer).leaves

Leaves of tree container.

>>> a = datastructuretools.TreeContainer(name='a')
>>> b = datastructuretools.TreeContainer(name='b')
>>> c = datastructuretools.TreeNode(name='c')
>>> d = datastructuretools.TreeNode(name='d')
>>> e = datastructuretools.TreeContainer(name='e')
>>> a.extend([b, c])
>>> b.extend([d, e])
>>> for leaf in a.leaves:
...     print(leaf.name)
...
d
e
c

Returns tuple.

(TreeContainer).nodes

The collection of tree nodes produced by iterating tree container depth-first.

>>> a = datastructuretools.TreeContainer()
>>> b = datastructuretools.TreeContainer()
>>> c = datastructuretools.TreeNode()
>>> d = datastructuretools.TreeNode()
>>> e = datastructuretools.TreeContainer()
>>> a.extend([b, c])
>>> b.extend([d, e])
>>> nodes = a.nodes
>>> len(nodes)
5
>>> nodes[0] is a
True
>>> nodes[1] is b
True
>>> nodes[2] is d
True
>>> nodes[3] is e
True
>>> nodes[4] is c
True

Returns tuple.

(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.

(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.

(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.

RhythmTreeContainer.rtm_format

The node’s RTM format:

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

Returns string.

(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.

Read/write properties

(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.

Methods

(TreeContainer).append(node)

Appends node to tree container.

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

Returns none.

(TreeContainer).extend(argument)

Extendes argument against tree container.

>>> a = datastructuretools.TreeContainer()
>>> b = datastructuretools.TreeNode()
>>> c = datastructuretools.TreeNode()
>>> a
TreeContainer()
>>> a.extend([b, c])
>>> a
TreeContainer(
    children=(
        TreeNode(),
        TreeNode(),
        )
    )

Returns none.

(TreeContainer).index(node)

Indexes node in tree container.

>>> a = datastructuretools.TreeContainer()
>>> b = datastructuretools.TreeNode()
>>> c = datastructuretools.TreeNode()
>>> a.extend([b, c])
>>> a.index(b)
0
>>> a.index(c)
1

Returns nonnegative integer.

(TreeContainer).insert(i, node)

Insert node in tree container at index i.

>>> a = datastructuretools.TreeContainer()
>>> b = datastructuretools.TreeNode()
>>> c = datastructuretools.TreeNode()
>>> d = datastructuretools.TreeNode()
>>> a.extend([b, c])
>>> a
TreeContainer(
    children=(
        TreeNode(),
        TreeNode(),
        )
    )
>>> a.insert(1, d)
>>> a
TreeContainer(
    children=(
        TreeNode(),
        TreeNode(),
        TreeNode(),
        )
    )

Return None.

(TreeContainer).pop(i=-1)

Pops node i from tree container.

>>> a = datastructuretools.TreeContainer()
>>> b = datastructuretools.TreeNode()
>>> c = datastructuretools.TreeNode()
>>> a.extend([b, c])
>>> a
TreeContainer(
    children=(
        TreeNode(),
        TreeNode(),
        )
    )
>>> node = a.pop()
>>> node == c
True
>>> a
TreeContainer(
    children=(
        TreeNode(),
        )
    )

Returns node.

(TreeContainer).remove(node)

Remove node from tree container.

>>> a = datastructuretools.TreeContainer()
>>> b = datastructuretools.TreeNode()
>>> c = datastructuretools.TreeNode()
>>> a.extend([b, c])
>>> a
TreeContainer(
    children=(
        TreeNode(),
        TreeNode(),
        )
    )
>>> a.remove(b)
>>> a
TreeContainer(
    children=(
        TreeNode(),
        )
    )

Returns none.

Special methods

RhythmTreeContainer.__add__(argument)

Concatenate containers self and argument. The operation c = a + b returns a new RhythmTreeContainer c with the content of both a and b, and a preprolated_duration equal to the sum of the durations of a and b. The operation is non-commutative: the content of the first operand will be placed before the content of the second operand:

>>> a = rhythmtreetools.RhythmTreeParser()('(1 (1 1 1))')[0]
>>> b = rhythmtreetools.RhythmTreeParser()('(2 (3 4))')[0]
>>> c = a + b
>>> c.preprolated_duration
Duration(3, 1)
>>> print(format(c))
rhythmtreetools.RhythmTreeContainer(
    children=(
        rhythmtreetools.RhythmTreeLeaf(
            preprolated_duration=durationtools.Duration(1, 1),
            is_pitched=True,
            ),
        rhythmtreetools.RhythmTreeLeaf(
            preprolated_duration=durationtools.Duration(1, 1),
            is_pitched=True,
            ),
        rhythmtreetools.RhythmTreeLeaf(
            preprolated_duration=durationtools.Duration(1, 1),
            is_pitched=True,
            ),
        rhythmtreetools.RhythmTreeLeaf(
            preprolated_duration=durationtools.Duration(3, 1),
            is_pitched=True,
            ),
        rhythmtreetools.RhythmTreeLeaf(
            preprolated_duration=durationtools.Duration(4, 1),
            is_pitched=True,
            ),
        ),
    preprolated_duration=durationtools.Duration(3, 1),
    )

Returns new RhythmTreeContainer.

RhythmTreeContainer.__call__(pulse_duration)

Generate Abjad score components:

>>> rtm = '(1 (1 (2 (1 1 1)) 2))'
>>> tree = rhythmtreetools.RhythmTreeParser()(rtm)[0]
>>> tree((1, 4))
[FixedDurationTuplet(Duration(1, 4), "c'16 { 2/3 c'16 c'16 c'16 } c'8")]

Returns sequence of components.

(TreeContainer).__contains__(argument)

True if argument is in container. Otherwise false:

>>> container = datastructuretools.TreeContainer()
>>> a = datastructuretools.TreeNode()
>>> b = datastructuretools.TreeNode()
>>> container.append(a)
>>> a in container
True
>>> b in container
False

Returns true or false.

(TreeNode).__copy__()

Copies tree node.

(TreeContainer).__delitem__(i)

Deletes node i in tree container.

>>> container = datastructuretools.TreeContainer()
>>> leaf = datastructuretools.TreeNode()
>>> container.append(leaf)
>>> container.children == (leaf,)
True
>>> leaf.parent is container
True
>>> del(container[0])
>>> container.children == ()
True
>>> leaf.parent is None
True

Return None.

(AbjadObject).__eq__(argument)

Is true when ID of argument 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.

(TreeContainer).__getitem__(argument)

Gets item or slice identified by argument.

>>> a = datastructuretools.TreeContainer()
>>> b = datastructuretools.TreeNode()
>>> c = datastructuretools.TreeContainer()
>>> d = datastructuretools.TreeNode()
>>> e = datastructuretools.TreeNode()
>>> f = datastructuretools.TreeNode()
>>> a.extend([b, c, f])
>>> c.extend([d, e])
>>> a[0] is b
True
>>> a[1] is c
True
>>> a[2] is f
True

If i is a string, the container will attempt to return the single child node, at any depth, whose name matches i:

>>> foo = datastructuretools.TreeContainer(name='foo')
>>> bar = datastructuretools.TreeContainer(name='bar')
>>> baz = datastructuretools.TreeNode(name='baz')
>>> quux = datastructuretools.TreeNode(name='quux')
>>> foo.append(bar)
>>> bar.extend([baz, quux])
>>> foo['bar'] is bar
True
>>> foo['baz'] is baz
True
>>> foo['quux'] is quux
True

Return TreeNode instance.

RhythmTreeContainer.__graph__(**keywords)

The GraphvizGraph representation of the RhythmTreeContainer:

>>> rtm = '(1 (1 (2 (1 1 1)) 2))'
>>> tree = rhythmtreetools.RhythmTreeParser()(rtm)[0]
>>> graph = tree.__graph__()
>>> print(str(graph))
digraph G {
    graph [bgcolor=transparent,
        truecolor=true];
    node_0 [label="1",
        shape=triangle];
    node_1 [label="1",
        shape=box];
    node_2 [label="2",
        shape=triangle];
    node_3 [label="1",
        shape=box];
    node_4 [label="1",
        shape=box];
    node_5 [label="1",
        shape=box];
    node_6 [label="2",
        shape=box];
    node_0 -> node_1;
    node_0 -> node_2;
    node_0 -> node_6;
    node_2 -> node_3;
    node_2 -> node_4;
    node_2 -> node_5;
}
>>> topleveltools.graph(graph) 

Return GraphvizGraph instance.

(AbjadObject).__hash__()

Hashes Abjad object.

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

Returns integer.

(TreeContainer).__iter__()

Iterates tree container.

Yields children of tree container.

(TreeContainer).__len__()

Returns nonnegative integer number of nodes in container.

(AbjadObject).__ne__(argument)

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

Returns true or false.

RhythmTreeContainer.__repr__()

Gets interpreter representation of rhythm tree container.

Returns string.

RhythmTreeContainer.__setitem__(i, argument)

Set argument in self at nonnegative integer index i, or set argument in self at slice i. Replace contents of self[i] with argument. Attach parentage to contents of argument, and detach parentage of any replaced nodes.

>>> a = rhythmtreetools.RhythmTreeContainer()
>>> b = rhythmtreetools.RhythmTreeLeaf()
>>> c = rhythmtreetools.RhythmTreeLeaf()
>>> a.append(b)
>>> b.parent is a
True
>>> a.children == (b,)
True
>>> a[0] = c
>>> c.parent is a
True
>>> b.parent is None
True
>>> a.children == (c,)
True

Return None.