Skip to content

Commit

Permalink
release as qsurface (#34)
Browse files Browse the repository at this point in the history
(re)release as qsurface
  • Loading branch information
watermarkhu authored Nov 17, 2020
1 parent 4842b93 commit 8ee7f00
Show file tree
Hide file tree
Showing 71 changed files with 131 additions and 125 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest, check coverage
run: |
pytest --cov=opensurfacesim tests/ --cov-report=xml -m "not plotting"
pytest --cov=qsurface tests/ --cov-report=xml -m "not plotting"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
flags: unittests
env_vars: OS,PYTHON
name: codecov-opensurfacesim
name: codecov-qsurface
fail_ci_if_error: false
path_to_write_report: ./codecov_report.gz
verbose: true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
!requirements.txt
!pytest.ini
test.py
opensurfacesim/decoders/mwpm/blossom5-v2.05.src/
qsurface/decoders/mwpm/blossom5-v2.05.src/
!qsurface/decoders/decoders.ini

.python-version
.vscode/
Expand Down
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@

# opensurfacesim

[![PyPI version](https://img.shields.io/pypi/v/opensurfacesim?color=blue)](https://pypi.org/project/opensurfacesim/)
![Build](https://github.com/watermarkhu/opensurfacesim/workflows/Build/badge.svg)
[![Documentation Status](https://readthedocs.org/projects/opensurfacesim/badge/?version=latest)](https://opensurfacesim.readthedocs.io/en/latest/?badge=latest)
[![codecov](https://codecov.io/gh/watermarkhu/OpenSurfaceSim/branch/master/graph/badge.svg?token=CWLVPDFF2L)](https://codecov.io/gh/watermarkhu/OpenSurfaceSim)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/watermarkhu/opensurfacesim/master?filepath=examples.ipynb)
![License](https://img.shields.io/pypi/l/opensurfacesim)
# Qsurface

[![PyPI version](https://img.shields.io/pypi/v/qsurface?color=blue)](https://pypi.org/project/qsurface/)
![Build](https://github.com/watermarkhu/qsurface/workflows/Build/badge.svg)
[![Documentation Status](https://readthedocs.org/projects/qsurface/badge/?version=latest)](https://qsurface.readthedocs.io/en/latest/?badge=latest)
[![codecov](https://codecov.io/gh/watermarkhu/Qsurface/branch/master/graph/badge.svg?token=CWLVPDFF2L)](https://codecov.io/gh/watermarkhu/qsurface)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/watermarkhu/qsurface/master?filepath=examples.ipynb)
![License](https://img.shields.io/pypi/l/qsurface)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4247617.svg)](https://doi.org/10.5281/zenodo.4247617)
[![Unitary Fund](https://img.shields.io/badge/Supported%20By-UNITARY%20FUND-brightgreen.svg?style=flat-the-badge)](http://unitary.fund)

Opensurfacesim is a simulation package for the surface code, and is designed to modularize 3 aspects of a surface code simulation.
Qsurface is a simulation package for the surface code, and is designed to modularize 3 aspects of a surface code simulation.

1. The surface code
2. The error model
3. The used decoder

New types of surface codes, error modules and decoders can be added to opensurfacesim by using the included templates for each of the three core module categories.
New types of surface codes, error modules and decoders can be added to Qsurface by using the included templates for each of the three core module categories.

The current included decoders are:

Expand All @@ -37,7 +37,7 @@ The compatibility of these decoders with the included surface codes are listed b
All required packages can be installed through:

```bash
pip install opensurfacesim
pip install qsurface
```

## Requirements
Expand All @@ -48,10 +48,10 @@ pip install opensurfacesim

### MWPM decoder

The MWPM decoder utilizes `networkx` for finding the minimal weights in a fully connected graph. This implementation is however rather slow compared to Kolmogorov's [Blossom V](https://pub.ist.ac.at/~vnk/software.html) algorithm. Blossom V has its own license and is thus not included with opensurfacesim. We do provided a single function to download and compile Blossom V, and to setup the integration with opensurfacesim automatically.
The MWPM decoder utilizes `networkx` for finding the minimal weights in a fully connected graph. This implementation is however rather slow compared to Kolmogorov's [Blossom V](https://pub.ist.ac.at/~vnk/software.html) algorithm. Blossom V has its own license and is thus not included with Qsurface. We do provided a single function to download and compile Blossom V, and to setup the integration with Qsurface automatically.

```python
>>> from opensurfacesim.decoders import mwpm
>>> from qsurface.decoders import mwpm
>>> mwpm.get_blossomv()
```

Expand All @@ -60,7 +60,7 @@ The MWPM decoder utilizes `networkx` for finding the minimal weights in a fully
To simulate the toric code and simulate with bitflip error for 10 iterations and decode with the MWPM decoder:

```python
>>> from opensurfacesim.main import initialize, run
>>> from qsurface.main import initialize, run
>>> code, decoder = initialize((6,6), "toric", "mwpm", enabled_errors=["pauli"])
>>> run(code, decoder, iterations=10, error_rates = {"p_bitflip": 0.1})
{'no_error': 8}
Expand All @@ -69,7 +69,7 @@ To simulate the toric code and simulate with bitflip error for 10 iterations and
Benchmarking of decoders can be enabled by attaching a *benchmarker* object to the decoder. See the docs for the syntax and information to setup benchmarking.

```python
>>> from opensurfacesim.main import initialize, run
>>> from qsurface.main import initialize, run
>>> benchmarker = BenchmarkDecoder({"decode":"duration"})
>>> run(code, decoder, iterations=10, error_rates = {"p_bitflip": 0.1}, benchmark=benchmarker)
{'no_error': 8,
Expand All @@ -81,15 +81,15 @@ Benchmarking of decoders can be enabled by attaching a *benchmarker* object to t

## Plotting

The figures in opensurfacesim allows for step-by-step visualization of the surface code simulation (and if supported the decoding process). Each figure logs its history such that the user can move backwards in time to view past states of the surface (and decoder). Press `h` when the figure is open for more information.
The figures in Qsurface allows for step-by-step visualization of the surface code simulation (and if supported the decoding process). Each figure logs its history such that the user can move backwards in time to view past states of the surface (and decoder). Press `h` when the figure is open for more information.

```python
>>> from opensurfacesim.main import initialize, run
>>> from qsurface.main import initialize, run
>>> code, decoder = initialize((6,6), "toric", "mwpm", enabled_errors=["pauli"], plotting=True, initial_states=(0,0))
>>> run(code, decoder, error_rates = {"p_bitflip": 0.1, "p_phaseflip": 0.1}, decode_initial=False)
```

![Interactive plotting on a 6x6 toric code.](https://raw.githubusercontent.com/watermarkhu/OpenSurfaceSim/master/images/toric-2d.gif "Iteractive plotting on a 2d axis")
![Interactive plotting on a 6x6 toric code.](https://raw.githubusercontent.com/watermarkhu/qsurface/master/images/toric-2d.gif "Iteractive plotting on a 2d axis")

Plotting will be performed on a 3D axis if faulty measurements are enabled.

Expand All @@ -98,24 +98,24 @@ Plotting will be performed on a 3D axis if faulty measurements are enabled.
>>> run(code, decoder, error_rates = {"p_bitflip": 0.05, "p_bitflip_plaq": 0.05}, decode_initial=False)
```

![Interactive plotting on a toric code with faulty measurements.](https://raw.githubusercontent.com/watermarkhu/OpenSurfaceSim/master/images/toric-3d.gif "Iteractive plotting on a 3d axis")
![Interactive plotting on a toric code with faulty measurements.](https://raw.githubusercontent.com/watermarkhu/qsurface/master/images/toric-3d.gif "Iteractive plotting on a 3d axis")

In IPython, inline images are created for each iteration of the plot, which can be tested in the [example notebook](https://mybinder.org/v2/gh/watermarkhu/opensurfacesim/master?filepath=examples.ipynb).
In IPython, inline images are created for each iteration of the plot, which can be tested in the [example notebook](https://mybinder.org/v2/gh/watermarkhu/qsurface/master?filepath=examples.ipynb).

## Command line interface

Simulations can also be initiated from the command line

```bash
$ python -m opensurfacesim -e pauli -D mwpm -C toric simulation --p_bitflip 0.1 -n 10
$ python -m qsurface -e pauli -D mwpm -C toric simulation --p_bitflip 0.1 -n 10
{'no_error': 8}
```

For more information on command line interface:

```bash
$ python -m opensurfacesim -h
usage: opensurfacesim
$ python -m qsurface -h
usage: qsurface
...
```

Expand Down
2 changes: 1 addition & 1 deletion docs/source/codes/elements.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Code elements
-------------

.. automodule:: opensurfacesim.codes.elements
.. automodule:: qsurface.codes.elements
:member-order: bysource
:inherited-members:
:members:
Expand Down
8 changes: 4 additions & 4 deletions docs/source/codes/planar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ Planar code
Simulation
^^^^^^^^^^

.. autoclass:: opensurfacesim.codes.planar.sim.PerfectMeasurements
.. autoclass:: qsurface.codes.planar.sim.PerfectMeasurements
:member-order: bysource
:inherited-members:
:members:

.. autoclass:: opensurfacesim.codes.planar.sim.FaultyMeasurements
.. autoclass:: qsurface.codes.planar.sim.FaultyMeasurements
:member-order: bysource
:inherited-members:
:members:

Plotting
^^^^^^^^

.. autoclass:: opensurfacesim.codes.planar.plot.PerfectMeasurements
.. autoclass:: qsurface.codes.planar.plot.PerfectMeasurements
:member-order: bysource
:inherited-members:
:members:

.. autoclass:: opensurfacesim.codes.planar.plot.FaultyMeasurements
.. autoclass:: qsurface.codes.planar.plot.FaultyMeasurements
8 changes: 4 additions & 4 deletions docs/source/codes/template.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ Template code
Simulation
^^^^^^^^^^

.. autoclass:: opensurfacesim.codes._template.sim.PerfectMeasurements
.. autoclass:: qsurface.codes._template.sim.PerfectMeasurements
:member-order: bysource
:inherited-members:
:members:

.. autoclass:: opensurfacesim.codes._template.sim.FaultyMeasurements
.. autoclass:: qsurface.codes._template.sim.FaultyMeasurements
:member-order: bysource
:inherited-members:
:members:

Plotting
^^^^^^^^

.. autoclass:: opensurfacesim.codes._template.plot.PerfectMeasurements
.. autoclass:: qsurface.codes._template.plot.PerfectMeasurements
:member-order: bysource
:inherited-members:
:members:

.. autoclass:: opensurfacesim.codes._template.plot.FaultyMeasurements
.. autoclass:: qsurface.codes._template.plot.FaultyMeasurements
8 changes: 4 additions & 4 deletions docs/source/codes/toric.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ Toric code
Simulation
^^^^^^^^^^

.. autoclass:: opensurfacesim.codes.toric.sim.PerfectMeasurements
.. autoclass:: qsurface.codes.toric.sim.PerfectMeasurements
:member-order: bysource
:inherited-members:
:members:

.. autoclass:: opensurfacesim.codes.toric.sim.FaultyMeasurements
.. autoclass:: qsurface.codes.toric.sim.FaultyMeasurements
:member-order: bysource
:inherited-members:
:members:

Plotting
^^^^^^^^

.. autoclass:: opensurfacesim.codes.toric.plot.PerfectMeasurements
.. autoclass:: qsurface.codes.toric.plot.PerfectMeasurements
:member-order: bysource
:inherited-members:
:members:

.. autoclass:: opensurfacesim.codes.toric.plot.FaultyMeasurements
.. autoclass:: qsurface.codes.toric.plot.FaultyMeasurements
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# -- Project information -----------------------------------------------------

project = "Open Surface code Simulations"
project = "Qsurface"
copyright = "2020, Mark Shui Hu"
author = "Mark Shui Hu"

Expand Down
8 changes: 4 additions & 4 deletions docs/source/decoders/mwpm.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
Information
-----------

.. automodule:: opensurfacesim.decoders.mwpm
.. automodule:: qsurface.decoders.mwpm
:members:

Simulation
----------

.. autoclass:: opensurfacesim.decoders.mwpm.sim.Toric
.. autoclass:: qsurface.decoders.mwpm.sim.Toric
:member-order: bysource
:inherited-members:
:members:

.. autoclass:: opensurfacesim.decoders.mwpm.sim.Planar
.. autoclass:: qsurface.decoders.mwpm.sim.Planar
:member-order: bysource
:inherited-members:
:members:
Expand All @@ -21,7 +21,7 @@ Simulation
Plotting
--------

.. automodule:: opensurfacesim.decoders.mwpm.plot
.. automodule:: qsurface.decoders.mwpm.plot
:member-order: bysource
:members:

Expand Down
2 changes: 1 addition & 1 deletion docs/source/decoders/template.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Template decoder
================

.. automodule:: opensurfacesim.decoders._template
.. automodule:: qsurface.decoders._template
:member-order: bysource
:inherited-members:
:members:
12 changes: 6 additions & 6 deletions docs/source/decoders/ufns.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Information
-----------

.. automodule:: opensurfacesim.decoders.ufns
.. automodule:: qsurface.decoders.ufns
:members:

.. automodule:: opensurfacesim.decoders.ufns.elements
.. automodule:: qsurface.decoders.ufns.elements
:member-order: bysource
:members:

Expand All @@ -14,18 +14,18 @@ Simulation

The following description also applies to `.ufns.sim.Planar`.

.. autoclass:: opensurfacesim.decoders.ufns.sim.Toric
.. autoclass:: qsurface.decoders.ufns.sim.Toric
:member-order: bysource
:inherited-members:
:members:

.. autoclass:: opensurfacesim.decoders.ufns.sim.Planar
.. autoclass:: qsurface.decoders.ufns.sim.Planar

Plotting
--------

.. autoclass:: opensurfacesim.decoders.ufns.plot.Toric
.. autoclass:: qsurface.decoders.ufns.plot.Toric

.. autoclass:: opensurfacesim.decoders.ufns.plot.Planar
.. autoclass:: qsurface.decoders.ufns.plot.Planar

.. [hu2020thesis] Hu, Mark Shui, *Quasilinear Time Decoding Algorithm for Topological Codes with High Error Threshold*, DOI: 10.13140/RG.2.2.13495.96162, 2020.
20 changes: 10 additions & 10 deletions docs/source/decoders/unionfind.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@
Information
-----------

.. automodule:: opensurfacesim.decoders.unionfind
.. automodule:: qsurface.decoders.unionfind
:members:

.. automodule:: opensurfacesim.decoders.unionfind.elements
.. automodule:: qsurface.decoders.unionfind.elements
:members:

Simulation
----------

The following description also applies to `.unionfind.sim.Planar`.

.. autoclass:: opensurfacesim.decoders.unionfind.sim.Toric
.. autoclass:: qsurface.decoders.unionfind.sim.Toric
:member-order: bysource
:inherited-members:
:members:

.. autoclass:: opensurfacesim.decoders.unionfind.sim.Planar
.. autoclass:: qsurface.decoders.unionfind.sim.Planar

Plotting
--------

.. autoclass:: opensurfacesim.decoders.unionfind.plot.Toric
.. autoclass:: qsurface.decoders.unionfind.plot.Toric

.. autoclass:: opensurfacesim.decoders.unionfind.plot::Toric.Figure2D
.. autoclass:: qsurface.decoders.unionfind.plot::Toric.Figure2D

.. autoclass:: opensurfacesim.decoders.unionfind.plot::Toric.Figure3D
.. autoclass:: qsurface.decoders.unionfind.plot::Toric.Figure3D

.. autoclass:: opensurfacesim.decoders.unionfind.plot.Planar
.. autoclass:: qsurface.decoders.unionfind.plot.Planar

.. autoclass:: opensurfacesim.decoders.unionfind.plot::Planar.Figure2D
.. autoclass:: qsurface.decoders.unionfind.plot::Planar.Figure2D

.. autoclass:: opensurfacesim.decoders.unionfind.plot::Planar.Figure3D
.. autoclass:: qsurface.decoders.unionfind.plot::Planar.Figure3D


.. [delfosse2017almost] Delfosse, Nicolas and Nickerson, Naomi H., *Almost-linear time decoding algorithm for topological codes*, arXiv preprint arXiv:1709.06218, 2017.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/errors/erasure.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Erasure error
-------------

.. automodule:: opensurfacesim.errors.erasure
.. automodule:: qsurface.errors.erasure
:members:
2 changes: 1 addition & 1 deletion docs/source/errors/pauli.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Pauli error
-----------

.. automodule:: opensurfacesim.errors.pauli
.. automodule:: qsurface.errors.pauli
:members:
Loading

0 comments on commit 8ee7f00

Please sign in to comment.