diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..1bcdb3da --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @ciaranra diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 00000000..04b72dca --- /dev/null +++ b/.github/workflows/python-app.yml @@ -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 diff --git a/.gitignore b/.gitignore index 9c538314..5298529c 100644 --- a/.gitignore +++ b/.gitignore @@ -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/ diff --git a/README.md b/README.md index 6ddbecf1..cc48d7c2 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/api_guide/simulators.rst b/docs/api_guide/simulators.rst index 8e102c36..7c56c431 100644 --- a/docs/api_guide/simulators.rst +++ b/docs/api_guide/simulators.rst @@ -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 @@ -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`. @@ -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}) diff --git a/pecos/simulators/_projectq_wrapper/bindings.py b/pecos/simulators/_projectq_wrapper/bindings.py index 6c25cb6d..8e836219 100644 --- a/pecos/simulators/_projectq_wrapper/bindings.py +++ b/pecos/simulators/_projectq_wrapper/bindings.py @@ -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, diff --git a/pecos/version.py b/pecos/version.py index fd2f1f55..621740db 100644 --- a/pecos/version.py +++ b/pecos/version.py @@ -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__ = 'ciaran@pecos.io' +__email__ = 'ciaran@pecos.io' # or ciaran.ryan-anderson@quantinuum.com diff --git a/setup.py b/setup.py index cdf16337..d81574ba 100644 --- a/setup.py +++ b/setup.py @@ -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=[ diff --git a/tests/test_random_circuits.py b/tests/test_random_circuits.py index 64ab20f8..d9bf3012 100644 --- a/tests/test_random_circuits.py +++ b/tests/test_random_circuits.py @@ -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))