Skip to content

Commit

Permalink
Release v0.7.1 (#352)
Browse files Browse the repository at this point in the history
### New features
* Added functions to generate the ``(A, b, c)`` triples for the
Fock-Bargmann representation of
several states and gates.
[(#338)](#338)

### Breaking changes

### Improvements

### Bug fixes
* Fixing a bug in `_transform_gaussian` in transformation.py that
modifies the input state's cov and means.
[(#349)](#349)
* Fixing a bug in `general_dyne` in physics/gaussian.py that returns the
wrong probability and outcomes with given projection.
[(#349)](#349)

### Documentation

### Tests

### Contributors
@SamFerracin @ziofil @sylviemonet

---------

Co-authored-by: Sebastián Duque Mesa <[email protected]>
Co-authored-by: JacobHast <[email protected]>
Co-authored-by: elib20 <[email protected]>
Co-authored-by: ziofil <[email protected]>
Co-authored-by: ziofil <[email protected]>
Co-authored-by: Luke Helt <[email protected]>
Co-authored-by: zeyueN <[email protected]>
Co-authored-by: Robbe De Prins <[email protected]>
Co-authored-by: Robbe De Prins (UGent-imec) <[email protected]>
Co-authored-by: Yuan <[email protected]>
Co-authored-by: Ryk <[email protected]>
Co-authored-by: Gabriele Gullì <[email protected]>
Co-authored-by: Yuan Yao <[email protected]>
Co-authored-by: Yuan Yao <[email protected]>
Co-authored-by: heltluke <[email protected]>
Co-authored-by: Tanner Rogalsky <[email protected]>
Co-authored-by: Jan Provazník <[email protected]>
  • Loading branch information
18 people authored Feb 28, 2024
1 parent e235882 commit 5a823a4
Show file tree
Hide file tree
Showing 50 changed files with 3,824 additions and 1,269 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RUN sh -c "$(wget -nv -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/mast

# upgrade pip and install package manager
RUN python -m pip install --no-cache-dir --upgrade pip
RUN pip install --no-cache-dir poetry==1.4.0
RUN pip install --no-cache-dir poetry==1.8.0
RUN poetry config virtualenvs.create false

### TEAR DOWN IMAGE SETUP ###
Expand Down
Empty file modified .devcontainer/post-install.sh
100755 → 100644
Empty file.
32 changes: 31 additions & 1 deletion .github/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
# Release 0.7.0 (current release)
# Release 0.7.1 (current release)

### New features
* Added functions to generate the ``(A, b, c)`` triples for the Fock-Bargmann representation of
several states and gates. [(#338)](https://github.com/XanaduAI/MrMustard/pull/338)

* Added support for python 3.11. [(#354)](https://github.com/XanaduAI/MrMustard/pull/354)

### Breaking changes

### Improvements

### Bug fixes
* Fixing a bug in `_transform_gaussian` in transformation.py that modifies the input state's cov and means.
[(#349)](https://github.com/XanaduAI/MrMustard/pull/349)
* Fixing a bug in `general_dyne` in physics/gaussian.py that returns the wrong probability and outcomes with given projection.
[(#349)](https://github.com/XanaduAI/MrMustard/pull/349)

### Documentation

### Tests

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


---

# Release 0.7.0

### New features
* Added a new interface for backends, as well as a `numpy` backend (which is now default). Users can run
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10']
python-version: ['3.9', '3.10', '3.11']
backend: [numpy, tensorflow]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.python-version }}
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.python-version }}-${{ matrix.backend }}
cancel-in-progress: true

steps:
Expand All @@ -32,7 +33,7 @@ jobs:
- name: Build and install Mr Mustard
run: |
python -m pip install --no-cache-dir --upgrade pip
pip install --no-cache-dir poetry==1.4.0
pip install --no-cache-dir poetry==1.8.0
poetry config virtualenvs.create false
poetry build
pip install dist/mrmustard*.whl
Expand All @@ -53,4 +54,4 @@ jobs:
run: julia --project="julia_pkg" -e "using Pkg; Pkg.instantiate()"

- name: Run tests
run: python -m pytest tests -p no:warnings --tb=native --backend=tensorflow
run: python -m pytest tests -p no:warnings --tb=native --backend=${{ matrix.backend }}
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3.11

- name: Install black formatter
run: |
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/tests_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Docs tests
on:
push:
branches:
- develop
pull_request:
paths:
- '.github/workflows/tests.yml'
- 'mrmustard/**'
- 'pyproject.toml'
- 'poetry.lock'
- 'pytest.ini'

jobs:
docs:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
HYPOTHESIS_PROFILE: ci

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --no-cache-dir --upgrade pip
pip install --no-cache-dir poetry==1.8.0
poetry config virtualenvs.create false
poetry install --extras "ray" --with dev
- name: Run tests
run: |
python -m pytest --doctest-modules mrmustard/physics/ansatze.py
python -m pytest --doctest-modules mrmustard/physics/representations.py
python -m pytest --doctest-modules mrmustard/lab_dev
4 changes: 2 additions & 2 deletions .github/workflows/tests_numpy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.11'

- name: Setup Julia
uses: julia-actions/setup-julia@v1
Expand All @@ -38,7 +38,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --no-cache-dir --upgrade pip
pip install --no-cache-dir poetry==1.4.0
pip install --no-cache-dir poetry==1.8.0
poetry config virtualenvs.create false
poetry install --extras "ray" --with dev
julia --project="julia_pkg" -e "using Pkg; Pkg.instantiate()"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests_tensorflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.11'

- name: Setup Julia
uses: julia-actions/setup-julia@v1
Expand All @@ -38,7 +38,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --no-cache-dir --upgrade pip
pip install --no-cache-dir poetry==1.4.0
pip install --no-cache-dir poetry==1.8.0
poetry config virtualenvs.create false
poetry install --extras "ray" --with dev
julia --project="julia_pkg" -e "using Pkg; Pkg.instantiate()"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3.11

- name: Build and install Mr Mustard
run: |
python -m pip install --no-cache-dir --upgrade pip
pip install --no-cache-dir poetry==1.4.0
pip install --no-cache-dir poetry==1.8.0
poetry config virtualenvs.create false
poetry build
pip install dist/mrmustard*.whl
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.9"
python: "3.11"
jobs:
post_install:
- "curl -fsSL https://install.julialang.org | sh -s -- --yes"
Expand Down
9 changes: 9 additions & 0 deletions doc/code/lab_dev.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
mrmustard.lab_dev
=================

.. toctree::
:maxdepth: 1

lab_dev/wires

.. currentmodule:: mrmustard.lab_dev
8 changes: 8 additions & 0 deletions doc/code/lab_dev/wires.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mrmustard.lab_dev.wires
=======================

.. currentmodule:: mrmustard.lab_dev.wires

.. automodapi:: mrmustard.lab_dev.wires
:no-heading:
:include-all-objects:
10 changes: 7 additions & 3 deletions doc/code/physics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ mrmustard.physics
:maxdepth: 1

physics/ansatze
physics/bargmann
physics/fock
physics/gaussian
physics/representations

.. toctree::
:maxdepth: 1

physics/bargmann
physics/utils/fock_calculations
physics/utils/gaussian_calculations

.. currentmodule:: mrmustard.physics

Expand Down
4 changes: 2 additions & 2 deletions doc/code/physics/ansatze.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Ansatze
=======
The representations' Ansatze
============================

.. currentmodule:: mrmustard.physics.ansatze

Expand Down
12 changes: 6 additions & 6 deletions doc/code/physics/bargmann.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Bargmann
========
Calculations on Bargmann objects
================================

.. currentmodule:: mrmustard.physics.bargmann
.. toctree::
:maxdepth: 1

.. automodapi:: mrmustard.physics.bargmann
:no-heading:
:include-all-objects:
utils/triples
utils/bargmann_calculations
4 changes: 2 additions & 2 deletions doc/code/physics/representations.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Representations
===============
The Fock-Bargmann and Fock Representations
==========================================

.. currentmodule:: mrmustard.physics.representations

Expand Down
8 changes: 8 additions & 0 deletions doc/code/physics/utils/bargmann_calculations.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Calculations on Bargmann objects
================================

.. currentmodule:: mrmustard.physics.bargmann

.. automodapi:: mrmustard.physics.bargmann
:no-heading:
:include-all-objects:
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Fock
====
Calculations on Fock objects
============================

.. currentmodule:: mrmustard.physics.fock

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Gaussian
=========
Calculations on Gaussian objects
================================

.. currentmodule:: mrmustard.physics.gaussian

Expand Down
8 changes: 8 additions & 0 deletions doc/code/physics/utils/triples.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Abc triples for Bargmann representation
=======================================

.. currentmodule:: mrmustard.physics.triples

.. automodapi:: mrmustard.physics.triples
:no-heading:
:include-all-objects:
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ Mr Mustard supports the following in a fully differentiable way:

code/mm
code/lab
code/lab_dev
code/physics
code/math
code/training
Expand Down
1 change: 0 additions & 1 deletion mrmustard/lab/abstract/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,6 @@ def get_modes(self, item) -> State:
fock_partitioned = fock.trace(self.dm(self.cutoffs), keep=item_idx)
return State(dm=fock_partitioned, modes=item)

# TODO: refactor
def __eq__(self, other) -> bool: # pylint: disable=too-many-return-statements
r"""Returns whether the states are equal."""
if self.num_modes != other.num_modes:
Expand Down
4 changes: 3 additions & 1 deletion mrmustard/lab/abstract/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ def _transform_gaussian(self, state: State, dual: bool) -> State:
State: the transformed state
"""
X, Y, d = self.XYd(allow_none=False) if not dual else self.XYd_dual(allow_none=False)
cov, means = gaussian.CPTP(state.cov, state.means, X, Y, d, state.modes, self.modes)
cov, means = gaussian.CPTP(
math.astensor(state.cov), math.astensor(state.means), X, Y, d, state.modes, self.modes
)
new_state = State(
cov=cov, means=means, modes=state.modes, _norm=state.norm
) # NOTE: assumes modes don't change
Expand Down
Loading

0 comments on commit 5a823a4

Please sign in to comment.