def test_ancestors_and_descendants_example(self, ops): """ Test that the ``ancestors`` and ``descendants`` methods return the expected result. """ circuit = CircuitGraph(ops, {}) ancestors = circuit.ancestors([ops[6]]) assert len(ancestors) == 3 for o_idx in (0, 1, 3): assert ops[o_idx] in ancestors descendants = circuit.descendants([ops[6]]) assert descendants == set([ops[8]])
def test_ancestors_and_descendants_example(self, queue, obs): """ Test that the `ancestors` and `descendants` methods return the expected result. """ circuit = CircuitGraph(queue, obs) ancestors = circuit.ancestors([6]) assert len(ancestors) == 3 for o_idx in (0, 1, 3): assert queue[o_idx] in circuit.get_ops(ancestors) descendants = circuit.get_ops(circuit.descendants([6])) assert descendants == [obs[1]]
def test_ancestors_and_descendants_example(self, ops, obs): """ Test that the ``ancestors`` and ``descendants`` methods return the expected result. """ circuit = CircuitGraph(ops, obs, Wires([0, 1, 2])) queue = ops + obs ancestors = circuit.ancestors([queue[6]]) assert len(ancestors) == 3 for o_idx in (0, 1, 3): assert queue[o_idx] in ancestors descendants = circuit.descendants([queue[6]]) assert descendants == set([queue[8]])