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 three mode interferometer using either mesh gives the correct gates
docstr_tok: ["Test","that","a","three","mode","interferometer","using","either","mesh","gives","the","correct","gates"]
code: def test_three_mode(self):
      """Test that a three mode interferometer using either mesh gives the correct gates"""
      N = 3
      wires = range(N)
  
      theta = [0.321, 0.4523, 0.21321]
      phi = [0.234, 0.324, 0.234]
      varphi = [0.42342, 0.234, 0.1121]
  
      op_rect = qml.Interferometer(
          theta, phi, varphi, wires=wires, mesh="rectangular"
      )
      op_tria = qml.Interferometer(
          theta, phi, varphi, wires=wires, mesh="triangular"
      )
  
      # Test rectangular mesh
      rec = op_rect.expand()
      assert len(rec) == 6
  
      expected_bs_wires = [[0, 1], [1, 2], [0, 1]]
  
      for idx, op in enumerate(rec[:3]):
          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[3:]):
          assert isinstance(op, qml.Rotation)
          assert op.parameters == [varphi[idx]]
          assert op.wires == Wires([idx])
  
      # Test triangular mesh
      rec = op_tria.expand()
      assert len(rec) == 6
  
      expected_bs_wires = [[1, 2], [0, 1], [1, 2]]
  
      for idx, op in enumerate(rec[:3]):
          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[3:]):
          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 7 for calling the TestInterferometer obj's underlying member method code with example usage: obj.test_three_mode() without return types