Skip to main content

Gate model library.

Project description

https://img.shields.io/pypi/v/dwave-gate.svg https://img.shields.io/pypi/pyversions/dwave-gate.svg https://circleci.com/gh/dwavesystems/dwave-gate.svg?style=svg https://codecov.io/gh/dwavesystems/dwave-gate/branch/master/graph/badge.svg

dwave-gate

dwave-gate is a software package for constructing, modifying and running quantum circuits on the included simulator. It provides a set of tools that enables you to:

  • Construct quantum circuits using an intuitive context-manager interface.

  • Utilize a comprehensive library of quantum gates with simple access to matrix representations, various decompositions, and more.

  • Simulate circuits on a performant (C++) state-vector simulator.

  • Easily create your own quantum gates and templates. Any circuit can be either directly applied in another circuit or converted into a quantum operation.

Example usage

This example uses the dwave.gate.Circuit object’s context manager to append operations to a two-qubit circuit.

import dwave.gate.operations as ops
from dwave.gate import Circuit

circuit = Circuit(2)

with circuit.context as (q, c):
    ops.X(q[0])
    ops.Hadamard(q[1])
    ops.CZ(q[0], q[1])
    ops.Hadamard(q[1])

You can run the dwave.gate.simulator simulator on such circuits,

>>> from dwave.gate.simulator import simulate
>>> simulate(circuit)

and then access the resulting state via the state attribute.

>>> circuit.state
array([0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j])

Installation

The simplest way to install dwave-gate is from PyPI:

pip install dwave-gate

It can also be installed from source by cloning this GitHub repository and running:

make install

The makefile will also simplify running tests (make test), coverage (make coverage), documentation (make docs), as well as formatting (make format) the code using the Black formatter (set to a line-length of 100) and isort. It’s available on both Unix as well as Windows systems, via the make.bat batch file.

Alternatively, the package can be built and installed in development mode using Python and pip. The simulator operations would need to be generated first by executing operation_generation.py, found in dwave/gate/simulator.

python setup.py build_ext --inplace
pip install -e .

Tests and coverage can be run using Pytest.

python -m pytest tests/ --cov=dwave.gate

License

Released under the Apache License 2.0. See LICENSE file.

Contributing

Ocean’s contributing guide has guidelines for contributing to Ocean packages.

Release Notes

dwave-gate uses reno to manage its release notes.

When making a contribution to dwave-gate that will affect users, create a new release note file by running

reno new your-short-descriptor-here

You can then edit the file created under releasenotes/notes/. Remove any sections not relevant to your changes. Commit the file along with your changes.

See reno’s user guide for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dwave-gate-0.3.1.tar.gz (351.9 kB view hashes)

Uploaded Source

Built Distributions

dwave_gate-0.3.1-cp312-cp312-win_amd64.whl (217.5 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

dwave_gate-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

dwave_gate-0.3.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

dwave_gate-0.3.1-cp312-cp312-macosx_11_0_arm64.whl (232.9 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

dwave_gate-0.3.1-cp312-cp312-macosx_10_9_x86_64.whl (247.2 kB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

dwave_gate-0.3.1-cp311-cp311-win_amd64.whl (218.8 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

dwave_gate-0.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

dwave_gate-0.3.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

dwave_gate-0.3.1-cp311-cp311-macosx_11_0_arm64.whl (233.9 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

dwave_gate-0.3.1-cp311-cp311-macosx_10_9_x86_64.whl (248.6 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

dwave_gate-0.3.1-cp310-cp310-win_amd64.whl (218.8 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

dwave_gate-0.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

dwave_gate-0.3.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.1 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

dwave_gate-0.3.1-cp310-cp310-macosx_11_0_arm64.whl (233.6 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

dwave_gate-0.3.1-cp310-cp310-macosx_10_9_x86_64.whl (247.9 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

dwave_gate-0.3.1-cp39-cp39-win_amd64.whl (218.4 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

dwave_gate-0.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

dwave_gate-0.3.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.1 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

dwave_gate-0.3.1-cp39-cp39-macosx_11_0_arm64.whl (234.1 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

dwave_gate-0.3.1-cp39-cp39-macosx_10_9_x86_64.whl (248.7 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

dwave_gate-0.3.1-cp38-cp38-win_amd64.whl (219.0 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

dwave_gate-0.3.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

dwave_gate-0.3.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

dwave_gate-0.3.1-cp38-cp38-macosx_11_0_arm64.whl (233.4 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

dwave_gate-0.3.1-cp38-cp38-macosx_10_9_x86_64.whl (248.2 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page