Skip to content

Commit

Permalink
Merge branch 'develop' into tfLabDev
Browse files Browse the repository at this point in the history
  • Loading branch information
apchytr authored Jan 20, 2025
2 parents 5a03c4d + 89c03b8 commit bb5b5a3
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 12 deletions.
2 changes: 1 addition & 1 deletion mrmustard/math/backend_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def hermite_renormalized(
"""

precision_bits = settings.PRECISION_BITS_HERMITE_POLY

shape = tuple(int(i) for i in shape) # ensure each item in the tuple is of the same dtype
if precision_bits == 128: # numba
if settings.STABLE_FOCK_CONVERSION:
G = vanilla_stable(tuple(shape), A, b, c)
Expand Down
2 changes: 1 addition & 1 deletion mrmustard/math/tensor_networks/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def draw(
labels=mode_labels,
font_size=12,
font_color="black",
font_family="FreeMono",
font_family="Monospace",
)

plt.title("Mr Mustard Network")
Expand Down
84 changes: 80 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ ipywidgets = "^8.1.3"
###################### The Tensorflow Section ######################
tensorflow = {version = "^2.15.0, <2.19.0" }
tensorflow-probability = {version = ">=0.22.0,<1.0", extras = ["tf"]}
tensorflow-intel = { version = "^2.15.0", platform = "win32" }
tensorflow-io-gcs-filesystem = [
{ version = ">= 0.23.1", markers = "platform_machine!='arm64' or platform_system!='Darwin'", python = ">=3.9,<3.12" },
{ version = "< 0.32.0", markers = "platform_system == 'Windows'", python = ">=3.9,<3.12" }
]
semantic-version = "^2.10.0"

[tool.poetry.extras]
Expand Down
10 changes: 5 additions & 5 deletions tests/test_lab_dev/test_states/test_dm.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_to_from_fock(self, modes):
def test_to_from_phase_space(self):
state0 = Coherent([0], x=1, y=2) >> Attenuator([0], 1.0)
cov, means, coeff = state0.phase_space(s=0) # batch = 1
assert coeff == 1.0
assert math.allclose(coeff, math.atleast_1d(1.0))
assert math.allclose(cov[0], np.eye(2) * settings.HBAR / 2)
assert math.allclose(means[0], np.array([1.0, 2.0]) * np.sqrt(settings.HBAR * 2))

Expand Down Expand Up @@ -167,15 +167,15 @@ def test_L2_norms(self):

def test_L2_norm(self):
state = Coherent([0], x=1).dm()
assert state.L2_norm == 1
assert math.allclose(state.L2_norm, 1)

def test_probability(self):
state1 = Coherent([0], x=1).dm()
assert state1.probability == 1
assert state1.to_fock(20).probability == 1
assert math.allclose(state1.probability, 1)
assert math.allclose(state1.to_fock(20).probability, 1)

state2 = Coherent([0], x=1).dm() / 3 + 2 * Coherent([0], x=-1).dm() / 3
assert state2.probability == 1
assert math.allclose(state2.probability, 1)
assert math.allclose(state2.to_fock(20).probability, 1)

state3 = Number([0], n=1, cutoffs=2).dm() / 2 + Number([0], n=2).dm() / 2
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lab_dev/test_states/test_ket.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def test_to_from_quadrature(self):

def test_L2_norm(self):
state = Coherent([0], x=1)
assert state.L2_norm == 1
assert math.allclose(state.L2_norm, 1)

def test_probability(self):
state1 = Coherent([0], x=1) / 3
Expand Down

0 comments on commit bb5b5a3

Please sign in to comment.