From 52d93aeb08ab0b2df52e08db3bb0fe92c5202c40 Mon Sep 17 00:00:00 2001 From: Anthony Date: Thu, 26 Sep 2024 14:38:53 -0400 Subject: [PATCH] init --- .gitignore | 2 ++ mrmustard/lab_dev/transformations/ggate.py | 10 +++++++--- tests/test_lab_dev/test_transformations/test_ggate.py | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 402b29781..0d80a32d7 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,5 @@ doc/code/api/* coverage.xml .coverage /.serialize_cache/ + +.venv diff --git a/mrmustard/lab_dev/transformations/ggate.py b/mrmustard/lab_dev/transformations/ggate.py index 98fd50abf..05a2156e4 100644 --- a/mrmustard/lab_dev/transformations/ggate.py +++ b/mrmustard/lab_dev/transformations/ggate.py @@ -55,10 +55,14 @@ def __init__( symplectic_trainable: bool = False, ): super().__init__(modes_out=modes, modes_in=modes, name="Ggate") - S = make_parameter(symplectic_trainable, symplectic, "symplectic", (None, None)) - self.parameter_set.add_parameter(S) - + self._add_parameter( + make_parameter(symplectic_trainable, symplectic, "symplectic", (None, None)) + ) self._representation = Bargmann.from_function( fn=lambda s: Unitary.from_symplectic(modes, s).bargmann_triple(), s=self.parameter_set.symplectic, ) + + @property + def symplectic(self): + return self.parameter_set.symplectic.value diff --git a/tests/test_lab_dev/test_transformations/test_ggate.py b/tests/test_lab_dev/test_transformations/test_ggate.py index 7a21ee844..ba4f1cb6c 100644 --- a/tests/test_lab_dev/test_transformations/test_ggate.py +++ b/tests/test_lab_dev/test_transformations/test_ggate.py @@ -30,6 +30,7 @@ def test_init(self): Eye = Ggate(modes=[0], symplectic=math.eye(2)) assert isinstance(Eye, Ggate) assert Eye.name == "Ggate" + assert math.allclose(Eye.symplectic, math.eye(2)) def test_ggate_is_unitary_1mode(self): """Test that the Ggate applied to its dual is the identity."""