Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
apchytr committed Sep 18, 2024
1 parent 8e74234 commit ecaf961
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion mrmustard/lab_dev/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

from .states import State, Number, QuadratureEigenstate
from .circuit_components import CircuitComponent
from .circuit_components_utils import BtoQ

__all__ = ["Sampler", "PNRSampler", "HomodyneSampler"]

Expand Down
2 changes: 1 addition & 1 deletion mrmustard/lab_dev/states/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def quadrature_distribution(self, quad: Vector, phi: float = 0.0) -> ComplexTens
quad = math.astensor(quad)
if len(quad.shape) != 1 and len(quad.shape) != self.n_modes:
raise ValueError(
f"The dimensionality of quad should be 1, or match the number of modes."
"The dimensionality of quad should be 1, or match the number of modes."
)

if len(quad.shape) == 1:
Expand Down
5 changes: 3 additions & 2 deletions tests/test_lab_dev/test_states/test_states_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# pylint: disable=protected-access, unspecified-encoding, missing-function-docstring, expression-not-assigned, pointless-statement

import numpy as np
from itertools import product
from ipywidgets import Box, HBox, VBox, HTML
from plotly.graph_objs import FigureWidget
import pytest
Expand Down Expand Up @@ -221,8 +222,8 @@ def test_quadrature_multimode_ket(self):
x, y = 1, 2
state = Coherent(modes=[0, 1], x=x, y=y)
q = np.linspace(-10, 10, 100)
quad = math.transpose(math.astensor([q, q]))
psi_q = coherent_state_quad(q, x, y) * coherent_state_quad(q, x, y)
quad = math.astensor(list(product(q, repeat=state.n_modes)))
psi_q = math.kron(coherent_state_quad(q, x, y), coherent_state_quad(q, x, y))
assert math.allclose(state.quadrature(quad), psi_q)
assert math.allclose(state.quadrature_distribution(q), abs(psi_q) ** 2)
assert math.allclose(state.to_fock(100).quadrature(quad), psi_q)
Expand Down

0 comments on commit ecaf961

Please sign in to comment.