-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into adding-fixtures
- Loading branch information
Showing
13 changed files
with
114 additions
and
18 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
:orphan: | ||
|
||
qbraid_qir.cirq | ||
================= | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
sphinx~=7.2.6 | ||
sphinx-autodoc-typehints>=1.24,<1.26 | ||
sphinx-rtd-theme~=1.3.0 | ||
sphinx-rtd-theme~=2.0.0 | ||
docutils<0.21 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
pyqir~=0.10.0 | ||
qbraid==0.5.0.dev20231129222445 | ||
qbraid==0.5.0.dev20231213012035 | ||
cirq-core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Copyright (C) 2023 qBraid | ||
# | ||
# This file is part of the qBraid-SDK | ||
# | ||
# The qBraid-SDK is free software released under the GNU General Public License v3 | ||
# or later. You can redistribute and/or modify it under the terms of the GPL v3. | ||
# See the LICENSE file in the project root or <https://www.gnu.org/licenses/gpl-3.0.html>. | ||
# | ||
# THERE IS NO WARRANTY for the qBraid-SDK, as per Section 15 of the GPL v3. | ||
""" | ||
Test functions that preprocess Cirq circuits before conversion to QIR. | ||
""" | ||
import cirq | ||
import numpy as np | ||
import pytest | ||
|
||
from qbraid_qir.cirq.convert import _preprocess_circuit | ||
|
||
|
||
@pytest.fixture | ||
def gridqubit_circuit(): | ||
qubits = [cirq.GridQubit(x, 0) for x in range(4)] | ||
circuit = cirq.Circuit(cirq.H(q) for q in qubits) | ||
yield circuit | ||
|
||
|
||
@pytest.fixture | ||
def namedqubit_circuit(): | ||
qubits = [cirq.NamedQubit(f"q{i}") for i in range(4)] | ||
circuit = cirq.Circuit(cirq.H(q) for q in qubits) | ||
yield circuit | ||
|
||
|
||
def test_convert_gridqubits_to_linequbits(gridqubit_circuit): | ||
linequbit_circuit = _preprocess_circuit(gridqubit_circuit) | ||
for qubit in linequbit_circuit.all_qubits(): | ||
assert isinstance(qubit, cirq.LineQubit), "Qubit is not a LineQubit" | ||
assert np.allclose( | ||
linequbit_circuit.unitary(), gridqubit_circuit.unitary() | ||
), "Circuits are not equal" | ||
|
||
|
||
def test_convert_namedqubits_to_linequbits(namedqubit_circuit): | ||
linequbit_circuit = _preprocess_circuit(namedqubit_circuit) | ||
for qubit in linequbit_circuit.all_qubits(): | ||
assert isinstance(qubit, cirq.LineQubit), "Qubit is not a LineQubit" | ||
assert np.allclose( | ||
linequbit_circuit.unitary(), namedqubit_circuit.unitary() | ||
), "Circuits are not equal" | ||
|
||
|
||
def test_empty_circuit_conversion(): | ||
circuit = cirq.Circuit() | ||
converted_circuit = _preprocess_circuit(circuit) | ||
assert ( | ||
len(converted_circuit.all_qubits()) == 0 | ||
), "Converted empty circuit should have no qubits" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters