def test_quantizationtools_QGridContainer___eq___01(): a = quantizationtools.QGridContainer(preprolated_duration=1, children=[]) b = quantizationtools.QGridContainer(preprolated_duration=1, children=[]) assert format(a) == format(b) assert a != b
def test_quantizationtools_QGridContainer___copy___01(): tree = quantizationtools.QGridContainer( preprolated_duration=1, children=[ quantizationtools.QGridLeaf(preprolated_duration=1), quantizationtools.QGridContainer( preprolated_duration=2, children=[ quantizationtools.QGridLeaf(preprolated_duration=3), quantizationtools.QGridContainer( preprolated_duration=4, children=[ quantizationtools.QGridLeaf( preprolated_duration=1), quantizationtools.QGridLeaf( preprolated_duration=1), quantizationtools.QGridLeaf(preprolated_duration=1) ]) ]), quantizationtools.QGridLeaf(preprolated_duration=2) ]) copied = copy.copy(tree) assert format(tree) == format(copied) assert tree is not copied assert tree[0] is not copied[0] assert tree[1] is not copied[1] assert tree[2] is not copied[2]
def test_quantizationtools_QGrid___eq___02(): a = quantizationtools.QGrid( root_node=quantizationtools.QGridContainer( preprolated_duration=1, children=[ quantizationtools.QGridLeaf( preprolated_duration=1, q_event_proxies=[ quantizationtools.QEventProxy( quantizationtools.SilentQEvent(100), 0.5, ), ], ), ], ), next_downbeat=quantizationtools.QGridLeaf( preprolated_duration=1, q_event_proxies=[ quantizationtools.QEventProxy( quantizationtools.TerminalQEvent(200), 0.9, ), ], ), ) b = quantizationtools.QGrid( root_node=quantizationtools.QGridContainer( preprolated_duration=1, children=[ quantizationtools.QGridLeaf( preprolated_duration=1, q_event_proxies=[ quantizationtools.QEventProxy( quantizationtools.SilentQEvent(100), 0.5, ), ], ), ], ), next_downbeat=quantizationtools.QGridLeaf( preprolated_duration=1, q_event_proxies=[ quantizationtools.QEventProxy( quantizationtools.TerminalQEvent(200), 0.9, ), ], ), ) assert format(a) == format(b) assert a != b
def test_quantizationtools_QGrid___eq___03(): a = quantizationtools.QGrid() b = quantizationtools.QGrid(root_node=quantizationtools.QGridContainer( preprolated_duration=1, children=[ quantizationtools.QGridLeaf( preprolated_duration=1, q_event_proxies=[ quantizationtools.QEventProxy( quantizationtools.SilentQEvent(100), 0.5) ], ), ], ), ) c = quantizationtools.QGrid(next_downbeat=quantizationtools.QGridLeaf( preprolated_duration=1, q_event_proxies=[ quantizationtools.QEventProxy( quantizationtools.TerminalQEvent(200), 0.9), ], ), ) d = quantizationtools.QGrid( root_node=quantizationtools.QGridContainer( preprolated_duration=1, children=[ quantizationtools.QGridLeaf( preprolated_duration=1, q_event_proxies=[ quantizationtools.QEventProxy( quantizationtools.SilentQEvent(100), 0.5), ], ), ], ), next_downbeat=quantizationtools.QGridLeaf( preprolated_duration=1, q_event_proxies=[ quantizationtools.QEventProxy( quantizationtools.TerminalQEvent(200), 0.9, ), ], ), ), assert a != b assert a != c assert a != d assert b != c assert b != d assert c != d
def test_quantizationtools_QGrid_pickle_01(): q_grid = quantizationtools.QGrid( root_node=quantizationtools.QGridContainer( preprolated_duration=1, children=[ quantizationtools.QGridLeaf( preprolated_duration=1, q_event_proxies=[ quantizationtools.QEventProxy( quantizationtools.SilentQEvent(100), 0.5, ), ], ), ], ), next_downbeat=quantizationtools.QGridLeaf( preprolated_duration=1, q_event_proxies=[ quantizationtools.QEventProxy( quantizationtools.TerminalQEvent(200), 0.9, ), ], ), ) pickled = pickle.loads(pickle.dumps(q_grid)) assert format(pickled) == format(q_grid) assert pickled is not q_grid assert pickled != q_grid, \ systemtools.TestManager.diff(pickled, q_grid, 'Diff:')
def test_quantizationtools_QGridContainer___eq___03(): a = quantizationtools.QGridContainer(preprolated_duration=1, children=[]) b = quantizationtools.QGridContainer(preprolated_duration=2, children=[]) c = quantizationtools.QGridContainer( preprolated_duration=1, children=[quantizationtools.QGridLeaf(preprolated_duration=1)]) d = quantizationtools.QGridContainer( preprolated_duration=2, children=[quantizationtools.QGridLeaf(preprolated_duration=1)]) e = quantizationtools.QGridContainer( preprolated_duration=2, children=[quantizationtools.QGridLeaf(2)]) assert a != b assert a != c assert a != d assert a != e assert b != c assert b != d assert b != e assert c != d assert c != e assert d != e
def subdivide_leaf(self, leaf, subdivisions): r'''Replace the ``QGridLeaf`` ``leaf`` contained in a ``QGrid`` by a ``QGridContainer`` containing ``QGridLeaves`` with durations equal to the ratio described in ``subdivisions`` Returns the ``QEventProxies`` attached to ``leaf``. ''' from abjad.tools import quantizationtools container = quantizationtools.QGridContainer( preprolated_duration=leaf.preprolated_duration, children=[ quantizationtools.QGridLeaf(preprolated_duration=subdivision) for subdivision in subdivisions ]) if leaf.parent is not None: index = leaf.parent.index(leaf) leaf.parent[index] = container # otherwise, our root node if just a QGridLeaf else: self._root_node = container return leaf.q_event_proxies
def test_quantizationtools_QGrid_subdivide_leaf_01(): q_grid = quantizationtools.QGrid() a = quantizationtools.QEventProxy(quantizationtools.PitchedQEvent(0, [0]), 0) b = quantizationtools.QEventProxy(quantizationtools.PitchedQEvent((9, 20), [1]), (9, 20)) c = quantizationtools.QEventProxy(quantizationtools.PitchedQEvent((1, 2), [2]), (1, 2)) d = quantizationtools.QEventProxy(quantizationtools.PitchedQEvent((11, 20), [3]), (11, 20)) e = quantizationtools.QEventProxy(quantizationtools.PitchedQEvent(1, [4]), 1) q_grid.leaves[0].q_event_proxies.extend([a, b, c, d]) q_grid.leaves[1].q_event_proxies.append(e) result = q_grid.subdivide_leaf(q_grid.leaves[0], (2, 3)) assert result == [a, b, c, d] root_node = quantizationtools.QGridContainer( children=[ quantizationtools.QGridLeaf(preprolated_duration=2, q_event_proxies=[]), quantizationtools.QGridLeaf(preprolated_duration=3, q_event_proxies=[]), ], preprolated_duration=1 ) assert format(q_grid.root_node) == format(root_node)