Skip to content

Commit

Permalink
Prepare release (#1)
Browse files Browse the repository at this point in the history
* prepare release

* change pr template

* mod tests

* change init

* sort imports

* rm CLIFFORD_CONJ

* readme & requirements changed

* fix tests

* fix ubuntu test

* fix ubuntu test

* rename file

* modify experiment

---------

Co-authored-by: Kazuki Tsuoka <[email protected]>
  • Loading branch information
king-p3nguin and Kazuki Tsuoka authored Oct 10, 2023
1 parent b7bc0d9 commit 3768c62
Show file tree
Hide file tree
Showing 17 changed files with 1,055 additions and 59 deletions.
6 changes: 3 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Before submitting, please check the following:
- Make sure you have tests for the new code and that test passes (run `pytest`)
- format added code and tests by `black -l 120 <filename>`
- Make sure you have tests for the new code and that test passes (run `tox`)
- format added code by `black -l 120 <filename>`
- If applicable, add a line to the [unreleased] part of CHANGELOG.md, following [keep-a-changelog](https://keepachangelog.com/en/1.0.0/).

Then, please fill in below:

**Context (if applicable):**
Expand Down
19 changes: 5 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,12 @@ jobs:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install -r requirements.txt
pip install -e .[test]
- name: Install tox
run: pip install tox tox-gh-actions

- name: Install graphix
run: |
python setup.py install
- name: Test with pytest
run: |
python -m pytest
- name: Run tox
run: tox
23 changes: 0 additions & 23 deletions .github/workflows/lint.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
**/build
dist/*
docs/source/gallery/**
.tox/
.vscode/
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include README.md
include MANIFEST.in
include LICENSE
include graphix_ibmq/version.py
include graphix_perceval/version.py
include requirements.txt
prune docs/*
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Graphix Perceval interface
<!--
![PyPI](https://img.shields.io/pypi/v/graphix-perceval)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/graphix-perceval) -->

Provides an interface to run MBQC pattern (`graphix.Pattern`) on Quandela's optical quantum devices as well as Perceval's simulator backends.

Requires [graphix](https://github.com/TeamGraphix/graphix) to generate the measurement pattern.

## Installation

install with `pip`

```bash
$ pip install graphix-perceval
```

<!-- This can be installed as part of graphix, by
```
$ pip install graphix[extra]
``` -->

## License

[Apache License 2.0](LICENSE)
1 change: 1 addition & 0 deletions graphix_perceval/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .converter import to_perceval
59 changes: 59 additions & 0 deletions graphix_perceval/clifford.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import numpy as np
import perceval.components as comp
import sympy as sp

# perceval representation of Clifford gates.
# see graphix.clifford module for the definitions and details of Clifford operatos for each index.
CLIFFORD_TO_PERCEVAL_BS = [
[comp.BS(theta=0.0)],
[comp.BS(theta=sp.pi, phi_bl=-sp.pi / 2, phi_br=-sp.pi / 2)],
[comp.BS(theta=sp.pi, phi_tl=-sp.pi / 2, phi_bl=sp.pi / 2, phi_tr=sp.pi / 2, phi_br=sp.pi / 2)],
[comp.BS(theta=0.0, phi_bl=sp.pi / 2, phi_br=sp.pi / 2)],
[comp.BS(theta=0.0, phi_br=sp.pi / 2)],
[comp.BS(theta=0.0, phi_br=-sp.pi / 2)],
[comp.BS(theta=sp.pi / 2, phi_bl=3 * sp.pi / 2, phi_br=3 * sp.pi / 2)],
[comp.BS(theta=sp.pi / 2, phi_tl=sp.pi / 2, phi_bl=-sp.pi / 2, phi_tr=-sp.pi / 2, phi_br=sp.pi / 2)],
[comp.BS(theta=sp.pi / 2, phi_bl=sp.pi / 2, phi_br=3 * sp.pi / 2)],
[comp.BS(theta=sp.pi, phi_tl=3 * sp.pi / 4, phi_tr=-3 * sp.pi / 4)],
[comp.BS(theta=sp.pi, phi_tl=-3 * sp.pi / 4, phi_tr=3 * sp.pi / 4)],
[comp.BS(theta=sp.pi / 2, phi_bl=sp.pi / 2, phi_br=sp.pi / 2)],
[comp.BS(theta=sp.pi / 2, phi_tl=3 * sp.pi / 4, phi_bl=sp.pi / 4, phi_tr=sp.pi / 4, phi_br=3 * sp.pi / 4)],
[comp.BS(theta=sp.pi / 2, phi_tr=sp.pi / 2, phi_br=3 * sp.pi / 2)],
[comp.BS(theta=sp.pi / 2, phi_tl=sp.pi / 2, phi_bl=3 * sp.pi / 2)],
[comp.BS(theta=sp.pi / 2, phi_tr=sp.pi, phi_br=3 * sp.pi)],
[comp.BS(theta=sp.pi / 2, phi_bl=sp.pi, phi_tr=3 * sp.pi / 4, phi_br=sp.pi / 4)],
[comp.BS(theta=sp.pi / 2, phi_tr=3 * sp.pi / 4, phi_br=5 * sp.pi / 4)],
[comp.BS(theta=sp.pi / 2, phi_bl=sp.pi, phi_tr=sp.pi / 4, phi_br=3 * sp.pi / 4)],
[comp.BS(theta=sp.pi / 2, phi_tr=5 * sp.pi / 4, phi_br=3 * sp.pi / 4)],
[comp.BS(theta=sp.pi / 2, phi_tl=5 * sp.pi / 4, phi_bl=3 * sp.pi / 4)],
[comp.BS(theta=sp.pi / 2, phi_tl=sp.pi / 2, phi_tr=sp.pi / 4, phi_br=5 * sp.pi / 4)],
[comp.BS(theta=sp.pi / 2, phi_bl=sp.pi / 2, phi_tr=sp.pi / 4, phi_br=5 * sp.pi / 4)],
[comp.BS(theta=sp.pi / 2, phi_tl=3 * sp.pi / 4, phi_bl=5 * sp.pi / 4)],
]

CLIFFORD_TO_PERCEVAL_POLAR = [
[comp.WP(delta=0.0, xsi=0.0)],
[comp.WP(delta=sp.pi / 2, xsi=sp.pi / 4), comp.PS(-sp.pi / 2)],
[comp.WP(delta=sp.pi / 2, xsi=0.0), comp.WP(delta=sp.pi / 2, xsi=sp.pi / 4), comp.PS(-sp.pi / 2)],
[comp.WP(delta=sp.pi / 2, xsi=0.0), comp.PS(-sp.pi / 2)],
[comp.WP(delta=-sp.pi / 4, xsi=0.0), comp.PS(sp.pi / 4)],
[comp.WP(delta=sp.pi / 4, xsi=0.0), comp.PS(7 * sp.pi / 4)],
[comp.WP(delta=sp.pi / 2, xsi=np.pi / 8), comp.PS(3 * sp.pi / 2)],
[comp.WP(delta=3 * sp.pi / 4, xsi=np.pi / 4), comp.PS(sp.pi)],
[comp.WP(delta=sp.pi / 2, xsi=sp.pi / 8), comp.WP(delta=sp.pi / 2, xsi=sp.pi / 4), comp.PS(sp.pi)],
[comp.WP(delta=-sp.pi / 4, xsi=sp.pi), comp.WP(delta=sp.pi / 2, xsi=sp.pi / 4), comp.PS(sp.pi)],
[comp.WP(delta=sp.pi / 4, xsi=sp.pi), comp.WP(delta=sp.pi / 2, xsi=sp.pi / 4), comp.PS(-sp.pi)],
[comp.WP(delta=sp.pi / 2, xsi=3 * sp.pi / 8), comp.PS(sp.pi / 2)],
[comp.WP(delta=sp.pi / 2, xsi=3 * sp.pi / 8), comp.WP(delta=sp.pi / 2, xsi=sp.pi / 4)],
[comp.WP(delta=sp.pi / 4, xsi=sp.pi / 4), comp.WP(delta=sp.pi / 2, xsi=0.0)],
[comp.WP(delta=sp.pi / 4, xsi=3 * sp.pi / 4), comp.WP(delta=sp.pi / 2, xsi=0.0)],
[comp.WP(delta=sp.pi / 4, xsi=sp.pi / 4), comp.PS(sp.pi)],
[comp.WP(delta=sp.pi / 4, xsi=0.0), comp.WP(delta=sp.pi / 2, xsi=sp.pi / 8)],
[comp.WP(delta=sp.pi / 4, xsi=0.0), comp.WP(delta=sp.pi / 2, xsi=3 * sp.pi / 8), comp.PS(sp.pi)],
[comp.WP(delta=sp.pi / 4, xsi=sp.pi / 2), comp.WP(delta=sp.pi / 2, xsi=3 * sp.pi / 8), comp.PS(sp.pi)],
[comp.WP(delta=sp.pi / 4, xsi=sp.pi / 2), comp.WP(delta=sp.pi / 2, xsi=5 * sp.pi / 8)],
[comp.WP(delta=sp.pi / 4, xsi=0.0), comp.WP(delta=sp.pi / 4, xsi=sp.pi / 4), comp.PS(sp.pi)],
[comp.WP(delta=sp.pi / 4, xsi=sp.pi / 4), comp.WP(delta=sp.pi / 2, xsi=sp.pi / 8)],
[comp.WP(delta=sp.pi / 4, xsi=0.0), comp.WP(delta=sp.pi / 4, xsi=3 * sp.pi / 4)],
[comp.WP(delta=sp.pi / 4, xsi=sp.pi / 2), comp.WP(delta=sp.pi / 4, xsi=sp.pi / 4), comp.PS(sp.pi)],
]
Loading

0 comments on commit 3768c62

Please sign in to comment.