class_docstr: Test that the template defines the correct decomposition.
class_docstr_tok: ["Test","that","the","template","defines","the","correct","decomposition","."]
docstr: Test the correctness of the TwoLocalSwapNetwork template including the
  gate count and order, the wires the operation acts on and the correct use
  of parameters in the circuit.
docstr_tok: ["Test","the","correctness","of","the","TwoLocalSwapNetwork","template","including","the","gate","count","and","order",",","the","wires","the","operation","acts","on","and","the","correct","use","of","parameters","in","the","circuit","."]
code: def test_ccl2_operations(
      self, wires, acquaintances, weights, fermionic, shift
  ):
      """Test the correctness of the TwoLocalSwapNetwork template including the
      gate count and order, the wires the operation acts on and the correct use
      of parameters in the circuit."""
  
      wire_order = range(wires)
      itrweights = (
          iter([])
          if weights is None or acquaintances is None
          else iter(weights)
      )
      qubit_pairs = [
          [[i, i + 1] for i in wire_order[(layer + shift) % 2 : -1 : 2]]
          for layer in range(wires)
      ]
  
      op = qml.templates.TwoLocalSwapNetwork(
          wire_order,
          acquaintances,
          weights,
          fermionic=fermionic,
          shift=shift,
      )
      queue = op.expand().operations
  
      # number of gates
      assert len(queue) == sum(
          2 * len(i)
          if acquaintances is not None
          and acquaintances([0, 1], [0, 1], 0.0)
          else len(i)
          for i in qubit_pairs
      )
  
      # complete gate set
      gate_order = []
      ac_op = acquaintances if acquaintances is not None else ()
      for pairs in qubit_pairs:
          for pair in pairs:
              if ac_op and ac_op([0, 1], [0, 1], 0.0):
                  gate_order.append(
                      ac_op(pair, pair, next(itrweights, 0.0))
                  )
              sw_op = (
                  qml.FermionicSWAP(np.pi, pair)
                  if fermionic
                  else qml.SWAP(pair)
              )
              gate_order.append(sw_op)
  
      for op1, op2 in zip(queue, gate_order):
          assert qml.equal(op1, op2)
  
imports: import pytest
  from pennylane import numpy
  import pennylane
label_desc: Use image node_id 1 for calling the TestDecomposition obj's underlying member method code with example usage: obj.test_ccl2_operations(wires, acquaintances, weights, fermionic, shift) without return types