Skip to content
This repository has been archived by the owner on Sep 20, 2022. It is now read-only.

Commit

Permalink
Merge pull request #430 from zapatacomputing/dev
Browse files Browse the repository at this point in the history
Merge dev to master
  • Loading branch information
alexjuda authored Sep 29, 2021
2 parents 5e2d20e + 918c9db commit 5fa4fd5
Show file tree
Hide file tree
Showing 54 changed files with 1,700 additions and 2,503 deletions.
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ def _read_readme():
"scipy>=1.4.1",
"sympy>=1.5",
"openfermion>=1.0.0",
"openfermioncirq==0.4.0",
"lea>=3.2.0",
"pyquil~=2.25",
"cirq>=0.9.1,<=0.10",
"overrides~=3.1",
"python-rapidjson",
],
extras_require=extras_require,
setup_requires=["setuptools_scm~=6.0"],
Expand Down
17 changes: 4 additions & 13 deletions src/python/zquantum/core/circuits/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
- defining quantum circuits with gates applied to qubits
- set of built-in gates (see imports in this `__init__`)
- import/export from/to Cirq and PyQuil circuits
- circuit (de)serialization to/from JSON-compatible dicts
Examples:
Expand Down Expand Up @@ -47,14 +46,6 @@
n_qubits=circuit.n_qubits
)
Conversion to other frameworks::
export_to_cirq(circuit)
circuit2 = import_from_cirq(cirq_circuit)
export_to_pyquil(circuit)
circuit3 = import_from_pyquil(pyquil_program)
(De)serialization::
to_dict(circuit)
circuit5 = circuit_from_dict(dict5)
Expand Down Expand Up @@ -103,8 +94,9 @@
- Adding its matrix to `zquantum.core.circuits._matrices`.
- Adding tests for conversion to other frameworks in:
- `zquantum.core.conversions.cirq_conversions_test`
- `zquantum.core.conversions.pyquil_conversions_test`
- `qeqiskit.conversions.circuit_conversions_test`
- `qecirq.conversions.circuit_conversions_test`
- `qeforest.conversions.circuit_conversions_test`
- Implement conversions. Some might work out of the box, e.g. if there's a gate with the
same name defined in PyQuil our converters will use it by default without need for
Expand Down Expand Up @@ -159,5 +151,4 @@
)
from ._testing import create_random_circuit
from ._wavefunction_operations import MultiPhaseOperation
from .conversions.cirq_conversions import export_to_cirq, import_from_cirq
from .conversions.pyquil_conversions import export_to_pyquil, import_from_pyquil
from .symbolic import natural_key, natural_key_revlex
18 changes: 13 additions & 5 deletions src/python/zquantum/core/circuits/_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,19 @@ def __init__(
n_qubits: Optional[int] = None,
):
self._operations = list(operations) if operations is not None else []
self._n_qubits = (
n_qubits
if n_qubits is not None
else _circuit_size_by_operations(self._operations)
)

if n_qubits:
cast_n_qubits = int(n_qubits)

if n_qubits != cast_n_qubits:
raise ValueError("Non-integer value passed.")

if cast_n_qubits <= 0:
raise ValueError("Non-positive value passed.")

self._n_qubits = n_qubits
else:
self._n_qubits = _circuit_size_by_operations(self._operations)

@property
def operations(self):
Expand Down
Loading

0 comments on commit 5fa4fd5

Please sign in to comment.