Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
Fix a small bug (#384)

Co-authored-by: grace-harper <119029214+grace-harper@users.noreply.github.com>

Update README.md (#377)

Co-authored-by: grace-harper <119029214+grace-harper@users.noreply.github.com>

Issue #247 - Replace `execute` with `backend.run()` in `qiskit-qec` (#381)

* replace `execute` with `backend.run()` in `test_repetitionmatcher.py`

* replace `execute` with `backend.run()` in  `test_circuitmatcher.py`

* replace `execute` with `backend.run()` in  `test_heavy_hex_decoder.py`

* replace `execute` with `backend.run()` in `faultsampler.py`

* replace `execute` with `backend.run()` in `faultenumerator.py`

* formatting

* re-format test_repetitionmatcher.py

---------

Co-authored-by: grace-harper <119029214+grace-harper@users.noreply.github.com>

scrap
  • Loading branch information
Grace authored and grace-harper committed Sep 19, 2023
1 parent 8dd69cc commit 0878c13
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 57 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ For information on how to contribute to this project, please take a look at our

## Acknowledgements

Development was partially supported by IARPA under contract W911NF-16-1-0114. All statements of fact, opinion or conclusions contained herein are those of the authors and should not be construed as representing the official views or policies of the US Government.
Development was partially supported by IARPA under contract W911NF-16-1-0114 and the DOE Office of Science National Quantum Information Science Research Centers, Co-design Center for Quantum Advantage (C2QA) under contract number DE-SC0012704. All statements of fact, opinion or conclusions contained herein are those of the authors and should not be construed as representing the official views or policies of the US Government.

----------------------------------------------------------------------------------------------------

Expand Down
1 change: 1 addition & 0 deletions scrap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
13 changes: 4 additions & 9 deletions src/qiskit_qec/analysis/faultenumerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from qiskit import QuantumCircuit
from qiskit.converters import circuit_to_dag
from qiskit.circuit.library import IGate, XGate, YGate, ZGate
from qiskit import execute, Aer
from qiskit_aer import Aer

from qiskit_qec.analysis.extensions import C_FAULT_ENUMERATOR

Expand Down Expand Up @@ -185,14 +185,9 @@ def gint(c):
else:
return c

result = execute(
circ,
Aer.get_backend("aer_simulator"),
method="stabilizer",
shots=1,
optimization_level=0,
seed_simulator=self.sim_seed,
).result()
backend = Aer.get_backend("aer_simulator")
options = {"method": "stabilizer", "shots": 1, "seed_simulator": self.sim_seed}
result = backend.run(circ, **options).result()
outcomes = result.get_counts(circ)
raw_outcome = list(outcomes.keys())[0]
outcome = list(map(gint, raw_outcome[::-1]))
Expand Down
13 changes: 4 additions & 9 deletions src/qiskit_qec/analysis/faultsampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from qiskit.dagcircuit.dagnode import DAGNode
from qiskit.converters import circuit_to_dag
from qiskit.circuit.library import IGate, XGate, YGate, ZGate
from qiskit import execute, Aer
from qiskit_aer import Aer

from qiskit_qec.utils.dag import node_name_label

Expand Down Expand Up @@ -150,14 +150,9 @@ def gint(c):
else:
return c

result = execute(
circ,
Aer.get_backend("aer_simulator"),
method="stabilizer",
shots=1,
optimization_level=0,
seed_simulator=self.sim_seed,
).result()
backend = Aer.get_backend("aer_simulator")
options = {"method": "stabilizer", "shots": 1, "seed_simulator": self.sim_seed}
result = backend.run(circ, **options).result()
outcomes = result.get_counts(circ)
raw_outcome = list(outcomes.keys())[0]
outcome = list(map(gint, raw_outcome[::-1]))
Expand Down
2 changes: 1 addition & 1 deletion src/qiskit_qec/linear/symplectic.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ def _build_hyper_partner(matrix, index: int) -> np.ndarray:
for i in range(ncols):
if heads[i] == 1:
result[i] = trans_e_index[pivot]
pivot = +1
pivot += 1

return result

Expand Down
4 changes: 2 additions & 2 deletions src/qiskit_qec/operators/pauli.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,11 @@ def to_instruction(self):
gate = {"I": IGate(), "X": XGate(), "Y": YGate(), "Z": ZGate()}[pauli]
else:
gate = PauliGate(pauli)
if not phase_exp[0]:
if not phase_exp:
return gate
# Add global phase
circuit = QuantumCircuit(self.num_qubits, name=str(self))
circuit.global_phase = -phase_exp[0] * pi / 2
circuit.global_phase = -phase_exp * pi / 2
circuit.append(gate, range(self.num_qubits))
return circuit.to_instruction()

Expand Down
13 changes: 4 additions & 9 deletions test/heavy_hex_codes/test_heavy_hex_decoder.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Test a heavy-hexagon code decoder"""
import unittest

from qiskit import execute, Aer
from qiskit_aer import Aer

from qiskit_qec.codes.hhc import HHC
from qiskit_qec.circuits.hhc_circuit import HHCCircuit
Expand Down Expand Up @@ -82,14 +82,9 @@ def no_faults_success(self, code, circ, dec, model, good=0, xbasis=False):
"""Test for correct behavior without faults."""
shots = 10
seed = 100
result = execute(
circ,
Aer.get_backend("aer_simulator"),
method="stabilizer",
shots=shots,
optimization_level=0,
seed_simulator=seed,
).result()
backend = Aer.get_backend("aer_simulator")
options = {"method": "stabilizer", "shots": shots, "seed_simulator": seed}
result = backend.run(circ, **options).result()
counts = result.get_counts(circ)
dec.update_edge_weights(model)
failures = 0
Expand Down
25 changes: 8 additions & 17 deletions test/matching/test_circuitmatcher.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Tests for the subsystem CSS circuit-level matching decoder."""
import unittest

from qiskit import execute, QuantumCircuit, Aer
from qiskit import QuantumCircuit
from qiskit_aer import Aer

from qiskit_qec.analysis.faultenumerator import FaultEnumerator
from qiskit_qec.decoders.circuit_matching_decoder import temp_syndrome
Expand Down Expand Up @@ -82,14 +83,9 @@ def test_no_errors(self):
"rustworkx",
False,
)
result = execute(
self.qc,
Aer.get_backend("aer_simulator"),
method="stabilizer",
shots=shots,
optimization_level=0,
seed_simulator=seed,
).result()
backend = Aer.get_backend("aer_simulator")
options = {"method": "stabilizer", "shots": shots, "seed_simulator": seed}
result = backend.run(self.qc, **options).result()
counts = result.get_counts(self.qc)
dec.update_edge_weights(self.pnm)
failures = 0
Expand Down Expand Up @@ -120,14 +116,9 @@ def test_no_errors_pymatching(self):
"pymatching",
False,
)
result = execute(
self.qc,
Aer.get_backend("aer_simulator"),
method="stabilizer",
shots=shots,
optimization_level=0,
seed_simulator=seed,
).result()
backend = Aer.get_backend("aer_simulator")
options = {"method": "stabilizer", "shots": shots, "seed_simulator": seed}
result = backend.run(self.qc, **options).result()
counts = result.get_counts(self.qc)
dec.update_edge_weights(self.pnm)
failures = 0
Expand Down
13 changes: 4 additions & 9 deletions test/matching/test_repetitionmatcher.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Tests for the subsystem CSS circuit-level matching decoder."""
import unittest

from qiskit import execute, Aer
from qiskit_aer import Aer

from qiskit_qec.analysis.faultenumerator import FaultEnumerator
from qiskit_qec.decoders.circuit_matching_decoder import temp_syndrome
Expand Down Expand Up @@ -52,14 +52,9 @@ def gint(c):
for logical in ["0", "1"]:
dec = RepetitionDecoder(self.code_circuit, self.pnm, method, False, logical)
qc = self.code_circuit.circuit[logical]
result = execute(
qc,
Aer.get_backend("aer_simulator"),
method="stabilizer",
shots=shots,
optimization_level=0,
seed_simulator=seed,
).result()
backend = Aer.get_backend("aer_simulator")
options = {"method": "stabilizer", "shots": shots, "seed_simulator": seed}
result = backend.run(qc, **options).result()
counts = result.get_counts(qc)
dec.update_edge_weights(self.pnm)
failures = 0
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ setenv =
VIRTUAL_ENV={envdir}
LANGUAGE=en_US
LC_ALL=en_US.utf-8
JUPYTER_PLATFORM_DIRS=1
deps = -r requirements.txt
-r requirements-dev.txt
commands =
Expand Down

0 comments on commit 0878c13

Please sign in to comment.