class_docstr: Tests that verify that the cond transform works as expect.
class_docstr_tok: ["Tests","that","verify","that","the","cond","transform","works","as","expect","."]
docstr: Test that qml.cond operationss Conditional operations as expected in two cases:
  1. When an else qfunc is provided;
  2. When qml.cond is used twice equivalent to using an else qfunc.
docstr_tok: ["Test","that","qml.cond","operationss","Conditional","operations","as","expected","in","two","cases",":","1",".","When","an","else","qfunc","is","provided",";","2",".","When","qml.cond","is","used","twice","equivalent","to","using","an","else","qfunc","."]
code: def test_cond_operationss_with_else(self, tape, terminal_measurement):
      """Test that qml.cond operationss Conditional operations as expected in two cases:
      1. When an else qfunc is provided;
      2. When qml.cond is used twice equivalent to using an else qfunc.
      """
      r = 1.234
  
      def f(x):
          qml.PauliX(1)
          qml.RY(x, wires=1)
          qml.PauliZ(1)
  
      def g(x):
          # pylint: disable=unused-argument
          qml.PauliY(1)
  
      tape = getattr(self, tape)(f, g, r, terminal_measurement)
      ops = tape.operations
      target_wire = qml.wires.Wires(1)
  
      assert len(ops) == 5
  
      assert ops[0].return_type == qml.measurements.MidMeasure
  
      assert isinstance(ops[1], qml.ops.Conditional)
      assert isinstance(ops[1].then_op, qml.PauliX)
      assert ops[1].then_op.wires == target_wire
  
      assert isinstance(ops[2], qml.ops.Conditional)
      assert isinstance(ops[2].then_op, qml.RY)
      assert ops[2].then_op.wires == target_wire
      assert ops[2].then_op.data == (r,)
  
      assert isinstance(ops[3], qml.ops.Conditional)
      assert isinstance(ops[3].then_op, qml.PauliZ)
      assert ops[3].then_op.wires == target_wire
  
      assert isinstance(ops[4], qml.ops.Conditional)
      assert isinstance(ops[4].then_op, qml.PauliY)
      assert ops[4].then_op.wires == target_wire
  
      # Check that: the measurement value is the same for true_fn conditional
      # ops
      assert ops[1].meas_val is ops[2].meas_val is ops[3].meas_val
  
      # However, it is not the same for the false_fn
      assert ops[3].meas_val is not ops[4].meas_val
  
      assert len(tape.measurements) == 1
      assert tape.measurements[0] is terminal_measurement
  
file_path: pennylane/tests/ops/op_math/test_condition.py
imports: import pytest
  import pennylane
  from pennylane.ops.op_math.condition import ConditionalTransformError
label_desc: Use image node_id 4 for calling the TestCond obj's underlying member method code with example usage: obj.test_cond_operationss_with_else(tape, terminal_measurement) without return types