Skip to content

Commit

Permalink
Update to 0.2.0 (#45)
Browse files Browse the repository at this point in the history
* Update .gitignore, reqs, fixed a test, changes for projectq

* Version bump to 0.2.0

* Adding .github
  • Loading branch information
qciaran committed Feb 8, 2024
1 parent ab04127 commit 95529ec
Show file tree
Hide file tree
Showing 9 changed files with 237 additions and 36 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @ciaranra
36 changes: 36 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Python application

on:
push:
branches: [ "master", "development" ]
pull_request:
branches: [ "master", "development" ]

permissions:
contents: read

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
- name: Test with pytest
run: |
pip install pytest-cov
pip install .
pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
182 changes: 170 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,172 @@
__pycache__
# Cython
*.pyc
*.pyd
**/build
dist
*.eggs
*.egg-info
*.cache
.pylintrc
.pytest_cache
/.idea
/.eggs
~*
jupyter/

# VSCode
.vscode/

# Do not track external files for C++
**/cuquantum_wrapper/extern/**/*

### Add custom ignores above this line ###
## Copied over from https://github.com/github/gitignore/blob/main/Python.gitignore
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ quantum error-correction protocols.

For questions or suggestions, please feel free to contact the author:

- Ciarán Ryan-Anderson, ciaran.ryan-anderson@swansea.ac.uk
- Ciarán Ryan-Anderson, ciaran.ryan-anderson@quantinuum.com

## Getting Started

Expand Down
14 changes: 7 additions & 7 deletions docs/api_guide/simulators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Simulators
==========

Quantum states and their dynamics are simulated by classes belonging to the namespace ``simulators``. PECOS contains a
stabilizer simulator called ``StabSim``.
stabilizer simulator called ``SparseSim``.


Expected Methods
Expand All @@ -18,8 +18,8 @@ the size of the quantum registry:



>>> from pecos.simulators import StabSim
>>> state = StabSim(4)
>>> from pecos.simulators import SparseSim
>>> state = SparseSim(4)

Note, for all simulators, the initial state of each qudit is the state :math:`|0\rangle`.

Expand Down Expand Up @@ -47,14 +47,14 @@ corresponding measurement results except that zero results are not returned.
Classes in the ``circuit_runners`` namespace combine ``QuantumCircuits`` and simulators to apply gates to simulated
uantum states. For a discussion about these classes see :ref:`api-circ-run`.

StabSim
-------
SparseSim
---------

Methods that specific to ``StabSim`` will now be described.
Methods that specific to ``SparseSim`` will now be described.

The ``print_stabs`` method prints a stabilizer table corresponding to the state currently store in the simulator:

>>> state = StabSim(3)
>>> state = SparseSim(3)
>>> state.run_gate('CNOT', {(0, 1)})
{}
>>> state.run_gate('X', {0})
Expand Down
4 changes: 2 additions & 2 deletions pecos/simulators/_projectq_wrapper/bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
'PhaseRot': MakeFunc(ops.R, angle=True).func, # Phase-shift: Same as Rz but with a 1 in upper left of matrix.
'TOFFOLI': MakeFunc(ops.Toffoli).func,
'CRZ': MakeFunc(ops.CRz, angle=True).func, # Controlled-Rz gate
'CRX': MakeFunc(ops.C(ops.Rx, n=1), angle=True).func, # Controlled-Rx
'CRY': MakeFunc(ops.C(ops.Ry, n=1), angle=True).func, # Controlled-Ry
'CRX': MakeFunc(ops.C(ops.Rx, 1), angle=True).func, # Controlled-Rx
'CRY': MakeFunc(ops.C(ops.Ry, 1), angle=True).func, # Controlled-Ry

'RXX': gates_two_qubit.RXX,
'RYY': gates_two_qubit.RYY,
Expand Down
10 changes: 5 additions & 5 deletions pecos/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
# limitations under the License.
# ========================================================================= #

__version__ = '0.1.2'
__author__ = 'Ciarán Ryan-Anderson'
__copyright__ = '2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS). Under the terms ' \
'of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software'
__copyright__ = ('2018 The PECOS Developers. 2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS). '
'Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in '
'this software')
__credits__ = ['Ciarán Ryan-Anderson', ]
__license__ = 'Apache 2'
__version__ = '0.2.dev'
__version__ = '0.2.0'
__maintainer__ = 'Ciarán Ryan-Anderson'
__email__ = '[email protected]'
__email__ = '[email protected]' # or [email protected]
22 changes: 14 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,24 @@
long_description_content_type="text/markdown",

packages=find_packages(),
python_requires='>=3.6',
python_requires=">=3.6",
install_requires=[
'numpy>=1.15.0',
'scipy>=1.1.0',
'matplotlib>=2.2.0',
'networkx>=2.1.0',
'sortedcontainers>=2.0.0',
"numpy>=1.15.0,<2.0",
"scipy>=1.1.0,<2.0",
"matplotlib>=2.2.0,<4.0",
"networkx>=2.1.0,<3.0",
"sortedcontainers>=2.0.0,<3.0",
],
tests_require=['pytest>=3.0.0'],
extras_require={
'all': ['cirq', 'cython', 'projectq'],
'simulators': ['cirq', 'cython', 'projectq'],
'simulators': [
'cython',
'projectq',
],
'all': [
'quantum-pecos[simulators]',
],

},
license='Apache 2',
classifiers=[
Expand Down
2 changes: 1 addition & 1 deletion tests/test_random_circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def generate_circuit(gates, num_qubits, circuit_depth):
if element == 'CNOT':
q = get_qubits(num_qubits, 2)
else:
q = int(get_qubits(num_qubits, 1))
q = get_qubits(num_qubits, 1)[0]

circuit.append((element, q))

Expand Down

0 comments on commit 95529ec

Please sign in to comment.