From cd35742fb4e118e430149cb96822f5cdeaa55301 Mon Sep 17 00:00:00 2001 From: Nicolas Quesada Date: Mon, 4 Nov 2019 14:40:54 -0500 Subject: [PATCH 1/2] Makes the interface of all the gates uniform. They now all return real symplectic matrices --- thewalrus/symplectic.py | 2 +- thewalrus/tests/test_symplectic.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/thewalrus/symplectic.py b/thewalrus/symplectic.py index 19a1ccfd8..6e698340c 100644 --- a/thewalrus/symplectic.py +++ b/thewalrus/symplectic.py @@ -279,4 +279,4 @@ def rotation(theta): array: rotation matrix by angle theta """ V = np.identity(1) * np.exp(1j * theta) - return V + return interferometer(V) diff --git a/thewalrus/tests/test_symplectic.py b/thewalrus/tests/test_symplectic.py index e6a8c3d78..0002031e8 100644 --- a/thewalrus/tests/test_symplectic.py +++ b/thewalrus/tests/test_symplectic.py @@ -175,9 +175,9 @@ def test_beamsplitter(self, tol): def test_rotation(self, tol): """Test that a rotation returns the correct symplectic for an abritrary angle""" theta = 0.98 - U = symplectic.rotation(theta) - S = symplectic.interferometer(U) - expected = np.block([[U.real, -U.imag], [U.imag, U.real]]) + S = symplectic.rotation(theta) + #S = symplectic.interferometer(U) + expected = np.block([[np.cos(theta), -np.sin(theta)], [np.sin(theta), np.cos(theta)]]) np.allclose(S, expected, atol=tol, rtol=0) From aeb449048273ca8b672fa8ee1e5fb518ef32d0bf Mon Sep 17 00:00:00 2001 From: Nicolas Quesada Date: Mon, 4 Nov 2019 15:08:21 -0500 Subject: [PATCH 2/2] Removes commented line --- thewalrus/tests/test_symplectic.py | 1 - 1 file changed, 1 deletion(-) diff --git a/thewalrus/tests/test_symplectic.py b/thewalrus/tests/test_symplectic.py index 0002031e8..c5c9f11b5 100644 --- a/thewalrus/tests/test_symplectic.py +++ b/thewalrus/tests/test_symplectic.py @@ -176,7 +176,6 @@ def test_rotation(self, tol): """Test that a rotation returns the correct symplectic for an abritrary angle""" theta = 0.98 S = symplectic.rotation(theta) - #S = symplectic.interferometer(U) expected = np.block([[np.cos(theta), -np.sin(theta)], [np.sin(theta), np.cos(theta)]]) np.allclose(S, expected, atol=tol, rtol=0)