Пример #1
0
 def test_1(self):
     ft = FractalTree(proportions=(1, 2, 3), tree_permutation_order=(3, 1, 2))
     ft.tempo = 60
     ft.value = 10
     ft.add_layer()
     ft.add_layer()
     self.assertEqual([node.fractal_order for node in ft.traverse_leaves()], [1, 2, 3, 3, 1, 2, 2, 3, 1])
Пример #2
0
 def test_1(self):
     ft = FractalTree(proportions=(1, 2, 3), tree_permutation_order=(3, 1, 2), value=10)
     ft.add_layer()
     ft.add_layer()
     for node in ft.get_layer(1):
         node.reduce_children(condition=lambda node: node.fractal_order == 1)
     self.assertEqual([node.fractal_order for node in ft.traverse_leaves()], [2, 3, 3, 2, 2, 3])
Пример #3
0
 def test_4(self):
     self.ft.multi = (3, 4)
     self.ft.add_layer()
     result = [leaf.value for leaf in self.ft.traverse_leaves()]
     ft = FractalTree(value=10, multi=(1, 1))
     ft.add_layer()
     expected = [leaf.value for leaf in ft.traverse_leaves()]
     self.assertEqual(expected, result)
Пример #4
0
 def test_2(self):
     ft = FractalTree(proportions=(1, 2, 3), tree_permutation_order=(3, 1, 2))
     ft.tempo = 60
     ft.value = 10
     ft.add_layer()
     ft.add_layer()
     self.assertEqual([node.value for node in ft.traverse_leaves()],
                      [Fraction(5, 6), Fraction(5, 3), Fraction(5, 2), Fraction(5, 6), Fraction(5, 18),
                       Fraction(5, 9),
                       Fraction(10, 9), Fraction(5, 3), Fraction(5, 9)])
Пример #5
0
class Test(TestCase):
    def setUp(self) -> None:
        self.ft = FractalTree(tree_permutation_order=[3, 1, 2],
                              proportions=[1, 2, 3],
                              value=10)

    def test_1(self):
        self.ft.add_layer()
        result = [(2, 1), (2, 2), (2, 3)]
        self.assertEqual(result,
                         [child.multi for child in self.ft.get_children()])

    def test_2(self):
        self.ft.multi = (1, 7)
        self.ft.add_layer()
        result = [leaf.value for leaf in self.ft.traverse_leaves()]
        ft = FractalTree(value=10, multi=(3, 1))
        ft.add_layer()
        expected = [leaf.value for leaf in ft.traverse_leaves()]
        self.assertEqual(expected, result)

    def test_3(self):
        self.ft.multi = (4, 1)
        self.ft.add_layer()
        result = [leaf.value for leaf in self.ft.traverse_leaves()]
        ft = FractalTree(value=10, multi=(1, 1))
        ft.add_layer()
        expected = [leaf.value for leaf in ft.traverse_leaves()]
        self.assertEqual(expected, result)

    def test_4(self):
        self.ft.multi = (3, 4)
        self.ft.add_layer()
        result = [leaf.value for leaf in self.ft.traverse_leaves()]
        ft = FractalTree(value=10, multi=(1, 1))
        ft.add_layer()
        expected = [leaf.value for leaf in ft.traverse_leaves()]
        self.assertEqual(expected, result)
Пример #6
0
 def test_2(self):
     ft = FractalTree(proportions=(1, 2, 3), tree_permutation_order=(3, 1, 2), value=10)
     ft.add_layer()
     ft.add_layer()
     for node in ft.get_layer(1):
         node.reduce_children(condition=lambda node: node.fractal_order == 1)
     actual = [node.value for node in ft.traverse_leaves()]
     expected = [Fraction(2, 1),
                 Fraction(3, 1),
                 Fraction(1, 1),
                 Fraction(2, 3),
                 Fraction(4, 3),
                 Fraction(2, 1)]
     self.assertEqual(actual, expected)