class_docstr: Test conversion of queues to DAGs
class_docstr_tok: ["Test","conversion","of","queues","to","DAGs"]
docstr: Test that the ``ancestors`` and ``descendants`` methods return the expected result.
docstr_tok: ["Test","that","the","``","ancestors","``","and","``","descendants","``","methods","return","the","expected","result","."]
code: 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 == [queue[8]]
  
imports: import io
  import contextlib
  import numpy
  import pytest
  import pennylane
  from pennylane import numpy
  from pennylane.resource import ResourcesOperation, Resources
  from pennylane.circuit_graph import CircuitGraph
  from pennylane.wires import Wires
label_desc: Use image node_id 3 for calling the TestCircuitGraph obj's underlying member method code with example usage: obj.test_ancestors_and_descendants_example(ops, obs) without return types