Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bumping tensorflow-macos to v2.15 #375

Merged
merged 7 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion .github/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
# Release 0.7.1 (current release)
# Release 0.7.2 (current release)

### New features
* Added a function ``to_fock`` to map different representations into Fock representation.
[(#355)](https://github.com/XanaduAI/MrMustard/pull/355)

* Added a new Abc triple for s-parametrized displacement gate.
[(#368)](https://github.com/XanaduAI/MrMustard/pull/368)

### Breaking changes

### Improvements

### Bug fixes

### Documentation

### Tests

### Contributors
[Samuele Ferracin](https://github.com/SamFerracin),
[Yuan Yao](https://github.com/sylviemonet)
[Filippo Miatto](https://github.com/ziofil)


---

# Release 0.7.1

### New features
* Added functions to generate the ``(A, b, c)`` triples for the Fock-Bargmann representation of
Expand Down
37 changes: 36 additions & 1 deletion mrmustard/math/lattice/strategies/compactFock/inputValidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,42 @@
from mrmustard.math.lattice.strategies.compactFock.singleLeftoverMode_grad import (
fock_representation_1leftoverMode_grad,
)
from thewalrus._hafnian import input_validation


def input_validation(A, rtol=1e-05, atol=1e-08):
SamFerracin marked this conversation as resolved.
Show resolved Hide resolved
"""Checks that the matrix A satisfies the requirements for Hafnian calculation.
These include:
* That the ``A`` is a NumPy array
* That ``A`` is square
* That ``A`` does not contain any NaNs
* That ``A`` is symmetric

.. note:: This function is an adaptation of the of an analogous method in The Walrus.

Args:
A (array): a NumPy array.
rtol (float): the relative tolerance parameter used in ``np.allclose``
atol (float): the absolute tolerance parameter used in ``np.allclose``

Returns:
bool: returns ``True`` if the matrix satisfies all requirements
"""

if not isinstance(A, np.ndarray):
raise TypeError("Input matrix must be a NumPy array.")

n = A.shape

if n[0] != n[1]:
raise ValueError("Input matrix must be square.")

if np.isnan(A).any():
raise ValueError("Input matrix must not contain NaNs.")

if not np.allclose(A, A.T, rtol=rtol, atol=atol):
raise ValueError("Input matrix must be symmetric.")

return True


def hermite_multidimensional_diagonal(A, B, G0, cutoffs, rtol=1e-05, atol=1e-08):
Expand Down
7 changes: 0 additions & 7 deletions mrmustard/physics/gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

from typing import Any, Optional, Sequence, Tuple, Union

from thewalrus.quantum import is_pure_cov

from mrmustard import math, settings
from mrmustard.math.tensor_wrappers.xptensor import XPMatrix, XPVector
from mrmustard.utils.typing import Matrix, Scalar, Vector
Expand Down Expand Up @@ -660,11 +658,6 @@ def number_cov(cov: Matrix, means: Vector) -> Matrix:
)


def is_mixed_cov(cov: Matrix) -> bool: # TODO: deprecate
SamFerracin marked this conversation as resolved.
Show resolved Hide resolved
r"""Returns ``True`` if the covariance matrix is mixed, ``False`` otherwise."""
return not is_pure_cov(math.asnumpy(cov))


def trace(cov: Matrix, means: Vector, Bmodes: Sequence[int]) -> Tuple[Matrix, Vector]:
r"""Returns the covariances and means after discarding the specified modes.

Expand Down
Loading
Loading