def test_sum(self): n1 = symrep.const(1) n2 = symrep.const(2) n = symrep.sum(n1, n2) self.assertEqual(n(0), 3) n = symrep.sum(n1, n1, n1) self.assertEqual(n(0), 3)
def test_collect_nodes(self): n1 = symrep.const(1) n2 = symrep.audio.sine(n1) n3 = symrep.sum(n1, n2) n4 = symrep.const(-2) n5 = symrep.product(n3, n4) nodes = symrep.collect_nodes(n5) self.assertEqual(len(nodes), 5) self.assertSetEqual( set(n.id for n in nodes), set((n1.id, n2.id, n3.id, n4.id, n5.id)))
def test_dot(self): n = symrep.product( symrep.audio.sine(symrep.const(2)), symrep.product( symrep.audio.sine(symrep.const(3)), symrep.sum( symrep.const(1), symrep.const(1), ) ) ) with open("test.dot", "w") as f: symrep.to_dot(n, f, name="test_dot")