class_docstr: Tests for the Interferometer from the pennylane.template.layers module.
class_docstr_tok: ["Tests","for","the","Interferometer","from","the","pennylane.template.layers","module","."]
docstr: Test that a 4 mode interferometer using rectangular mesh gives the correct gates
docstr_tok: ["Test","that","a","4","mode","interferometer","using","rectangular","mesh","gives","the","correct","gates"]
code: def test_four_mode_rect(self):
      """Test that a 4 mode interferometer using rectangular mesh gives the correct gates"""
      N = 4
      wires = range(N)
  
      theta = [0.321, 0.4523, 0.21321, 0.123, 0.5234, 1.23]
      phi = [0.234, 0.324, 0.234, 1.453, 1.42341, -0.534]
      varphi = [0.42342, 0.234, 0.4523, 0.1121]
  
      op = qml.Interferometer(theta, phi, varphi, wires=wires)
      rec = op.expand()
  
      assert len(rec) == 10
  
      expected_bs_wires = [
          [0, 1],
          [2, 3],
          [1, 2],
          [0, 1],
          [2, 3],
          [1, 2],
      ]
  
      for idx, op in enumerate(rec[:6]):
          assert isinstance(op, qml.Beamsplitter)
          assert op.parameters == [theta[idx], phi[idx]]
          assert op.wires == Wires(expected_bs_wires[idx])
  
      for idx, op in enumerate(rec[6:]):
          assert isinstance(op, qml.Rotation)
          assert op.parameters == [varphi[idx]]
          assert op.wires == Wires([idx])
  
file_path: pennylane/tests/templates/test_subroutines/test_interferometer.py
imports: import pytest
  import numpy
  import pennylane
  from pennylane.wires import Wires
label_desc: Use image node_id 8 for calling the TestInterferometer obj's underlying member method code with example usage: obj.test_four_mode_rect() without return types