Skip to content

Commit

Permalink
tests added for getitem
Browse files Browse the repository at this point in the history
  • Loading branch information
arsalan-motamedi committed Dec 2, 2024
1 parent a86232f commit 0bcfb79
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/test_lab_dev/test_states/test_gstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


from mrmustard import math
from mrmustard.lab_dev.states import Gdm, Gket, Vacuum
from mrmustard.lab_dev.states import DM, Gdm, Gket, Vacuum
from mrmustard.lab_dev.transformations import Unitary


Expand All @@ -44,6 +44,15 @@ def test_correctness(self):
u = Unitary.from_symplectic([0], sym)
assert g == Vacuum([0]) >> u

def test_getitem(self):
"Tests the getitem of the Gket"

psi = Gket([0])
assert psi == psi[0]

phi = Gket([0, 1])
assert isinstance(phi[0], DM)


class TestGdm:
r"""
Expand All @@ -60,3 +69,12 @@ def test_init(self):
assert math.allclose(rho.betas.value, math.astensor([0.2, 0.3]))
assert rho.symplectic.value.shape == (4, 4)
assert math.allclose(rho.probability, 1.0)

def test_getitem(self):
"Tests the getitem of Gdm"

rho = Gdm([0], 0.2)
assert rho == rho[0]

sigma = Gdm([0, 1], [0.5, 0.4])
assert isinstance(sigma[0], DM)

0 comments on commit 0bcfb79

Please sign in to comment.