Skip to content

Commit cbccecf

Browse files
authored
bump v0.6.0.dev5 to v0.6.0.dev6 + update pre-commit + fix regression version issue (#88)
1 parent b61aadc commit cbccecf

File tree

56 files changed

+80
-114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+80
-114
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.6.0
3+
rev: v5.0.0
44
hooks:
55
- id: trailing-whitespace
66
exclude: ^docs/reference/_autosummary/
@@ -15,7 +15,7 @@ repos:
1515
- id: debug-statements
1616

1717
- repo: https://github.com/crate-ci/typos
18-
rev: v1.21.0
18+
rev: v1.27.0
1919
hooks:
2020
- id: typos
2121
args: []
@@ -25,13 +25,13 @@ repos:
2525
)$
2626
2727
- repo: https://github.com/astral-sh/ruff-pre-commit
28-
rev: v0.4.3
28+
rev: v0.7.2
2929
hooks:
3030
- id: ruff
3131
args: [--fix, --exit-non-zero-on-fix]
3232

3333
- repo: https://github.com/psf/black
34-
rev: 24.4.2
34+
rev: 24.10.0
3535
hooks:
3636
- id: black
3737
exclude: |

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ build-backend = "setuptools.build_meta"
1515

1616
[project]
1717
name = "quantum-pecos"
18-
version = "0.6.0.dev5"
18+
version = "0.6.0.dev6"
1919
authors = [
2020
{name = "The PECOS Developers"},
2121
]

python/pecos/circuit_converters/checks2circuit.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ def compile(self, instr, abstract_circuit, mapping=None):
7676
if make_ticks["max_zdatas"]:
7777
# init [data ticks] meas
7878
temp = make_ticks["max_zdatas"] + 1
79-
if temp > largest_tick:
80-
largest_tick = temp
79+
largest_tick = max(temp, largest_tick)
8180

8281
if not make_ticks["max_xdatas"] and not make_ticks["max_zdatas"]:
8382
msg = "Something very weird happened!"
@@ -98,14 +97,12 @@ def compile(self, instr, abstract_circuit, mapping=None):
9897
tick_list = [ticks]
9998

10099
for t in tick_list:
101-
if t > largest_tick:
102-
largest_tick = t
100+
largest_tick = max(t, largest_tick)
103101

104102
else:
105103
tick = params["tick"]
106104

107-
if tick > largest_tick:
108-
largest_tick = tick
105+
largest_tick = max(tick, largest_tick)
109106

110107
# A quantum circuit with number of ticks == ``largest_tick``
111108
circuit = QuantumCircuit(largest_tick + 1, **gate_params)
@@ -220,8 +217,7 @@ def _check_ticks(abstract_circuit):
220217
break
221218

222219
if gate_symbol == "X check":
223-
if len(datas) > max_xdatas:
224-
max_xdatas = len(datas)
220+
max_xdatas = max(len(datas), max_xdatas)
225221

226222
elif len(datas) > max_zdatas:
227223
max_zdatas = len(datas)

python/pecos/error_models/generic_error_model.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from pecos.error_models.error_model_abc import ErrorModel
1919
from pecos.error_models.noise_impl.noise_initz_bitflip_leakage import noise_initz_bitflip_leakage
2020
from pecos.error_models.noise_impl.noise_meas_bitflip_leakage import noise_meas_bitflip_leakage
21-
from pecos.error_models.noise_impl.noise_meas_bitflip import noise_meas_bitflip
2221
from pecos.error_models.noise_impl.noise_sq_depolarizing_leakage import noise_sq_depolarizing_leakage
2322
from pecos.error_models.noise_impl.noise_tq_depolarizing_leakage import noise_tq_depolarizing_leakage
2423
from pecos.error_models.noise_impl_old.gate_groups import one_qubits, two_qubits

python/pecos/foreign_objects/object_pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class NamedObjectPool(ForeignObject):
2424

2525
def __init__(self, **objects: ForeignObject) -> None:
2626
self.objs = objects
27-
self.default = objects.get("default", None)
27+
self.default = objects.get("default")
2828

2929
def new_instance(self) -> None:
3030
"""Create new instance/internal state."""

python/pecos/simulators/compile_cython.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ def main():
2828
for d in cython_dirs:
2929
path = Path(current_location / d)
3030

31-
p = subprocess.Popen(
31+
p = subprocess.Popen( # noqa: S602
3232
"python setup.py build_ext --inplace", # noqa: S607
33-
shell=True, # noqa: S602
33+
shell=True,
3434
cwd=path,
3535
stderr=subprocess.PIPE,
3636
)

python/pecos/slr/block.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,16 @@ def __iter__(self):
6262
def iter(self):
6363
yield from self.__iter__()
6464

65-
def gen(self, target: object | str):
66-
65+
def gen(self, target: object | str, add_versions=True):
6766
if isinstance(target, str):
6867
if target == "qasm":
69-
target = QASMGenerator()
68+
target = QASMGenerator(add_versions=add_versions)
7069
else:
7170
msg = f"Code gen target '{target}' is not supported."
7271
raise NotImplementedError(msg)
7372

7473
target.generate_block(self)
7574
return target.get_output()
7675

77-
def qasm(self):
78-
return self.gen("qasm")
76+
def qasm(self, add_versions=True):
77+
return self.gen("qasm", add_versions=add_versions)

python/pecos/slr/gen_codes/gen_qasm.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515

1616

1717
class QASMGenerator:
18-
def __init__(self, includes: list[str] | None = None):
18+
def __init__(self, includes: list[str] | None = None, add_versions=True):
1919
self.output = []
2020
self.current_scope = None
2121
self.includes = includes
2222
self.cond = None
23+
self.add_versions = add_versions
2324

2425
def write(self, line):
2526
self.output.append(line)
@@ -37,8 +38,10 @@ def enter_block(self, block):
3738
for inc in self.includes:
3839
self.write(f'include "{str(inc)}";')
3940
else:
41+
# TODO: dump definitions in for things that are used instead of using includes
4042
self.write('include "hqslib1.inc";')
41-
self.write(f"// Generated using: PECOS version {__version__}")
43+
if self.add_versions:
44+
self.write(f"// Generated using: PECOS version {__version__}")
4245
for var in block.vars:
4346
var_def = self.process_var_def(var)
4447
self.write(var_def)
@@ -71,7 +74,6 @@ def generate_block(self, block):
7174
self.cond = None
7275

7376
elif block_name == "Repeat":
74-
7577
for _ in range(block.cond):
7678
self.block_op_loop(block)
7779
else:
@@ -180,7 +182,6 @@ def generate_op(self, op):
180182
op_list = op_str.split("\n")
181183
op_new = []
182184
for o in op_list:
183-
184185
o = o.strip()
185186
if o != "" and not o.startswith("//"):
186187
for qi in o.split(";"):
@@ -215,22 +216,31 @@ def process_qgate(self, op):
215216
op_str = self.qgate_tq_qasm(op)
216217

217218
else:
218-
219219
match sym:
220220
case "Measure":
221-
op_str = " ".join([f"measure {str(q)} -> {c};" for q, c in zip(op.qargs, op.cout, strict=True)])
221+
op_str = " ".join(
222+
[f"measure {str(q)} -> {c};" for q, c in zip(op.qargs, op.cout, strict=True)],
223+
)
222224

223225
case "F":
224-
op_str = " ".join([f"rx(pi/2) {str(q)};\nrz(pi/2) {str(q)};" for q in op.qargs])
226+
op_str = " ".join(
227+
[f"rx(pi/2) {str(q)};\nrz(pi/2) {str(q)};" for q in op.qargs],
228+
)
225229

226230
case "Fdg":
227-
op_str = " ".join([f"ry(-pi/2) {str(q)};\nrz(-pi/2) {str(q)};" for q in op.qargs])
231+
op_str = " ".join(
232+
[f"ry(-pi/2) {str(q)};\nrz(-pi/2) {str(q)};" for q in op.qargs],
233+
)
228234

229235
case "F4":
230-
op_str = " ".join([f"ry(-pi/2) {str(q)};\nrz(pi/2) {str(q)};" for q in op.qargs])
236+
op_str = " ".join(
237+
[f"ry(-pi/2) {str(q)};\nrz(pi/2) {str(q)};" for q in op.qargs],
238+
)
231239

232240
case "F4dg":
233-
op_str = " ".join([f"rx(-pi/2) {str(q)};\nrz(-pi/2) {str(q)};" for q in op.qargs])
241+
op_str = " ".join(
242+
[f"rx(-pi/2) {str(q)};\nrz(-pi/2) {str(q)};" for q in op.qargs],
243+
)
234244

235245
case "Prep":
236246
op_str = self.qgate_qasm(op, "reset")

python/pecos/tools/stabilizer_verification.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -913,8 +913,7 @@ def shortest_logicals(self, start_weight=None, delta=0, verbose=True, css=False)
913913

914914
qudit_set = self.data_qubits
915915

916-
if end_weight > len(qudit_set):
917-
end_weight = len(qudit_set)
916+
end_weight = min(end_weight, len(qudit_set))
918917

919918
state = self.state
920919
found = self._dist_mode_smallest(

requirements.txt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@
44
#
55
# pip-compile --extra=tests --no-annotate --no-emit-index-url --output-file=requirements.txt --strip-extras pyproject.toml
66
#
7-
annotated-types==0.6.0
8-
attrs==23.2.0
9-
contourpy==1.2.0
7+
annotated-types==0.7.0
8+
attrs==24.2.0
9+
contourpy==1.3.0
1010
cycler==0.12.1
11-
fonttools==4.50.0
12-
hypothesis==6.100.1
11+
fonttools==4.54.1
12+
hypothesis==6.116.0
1313
iniconfig==2.0.0
14-
kiwisolver==1.4.5
14+
kiwisolver==1.4.7
1515
markdown-it-py==3.0.0
16-
matplotlib==3.8.3
16+
matplotlib==3.9.2
1717
mdurl==0.1.2
1818
networkx==2.8.8
1919
numpy==1.26.4
20-
packaging==24.0
20+
packaging==24.1
2121
phir==0.3.3
22-
pillow==10.2.0
23-
pluggy==1.4.0
24-
pydantic==2.6.4
25-
pydantic-core==2.16.3
26-
pygments==2.17.2
27-
pyparsing==3.1.2
28-
pytest==8.1.1
22+
pillow==11.0.0
23+
pluggy==1.5.0
24+
pydantic==2.9.2
25+
pydantic-core==2.23.4
26+
pygments==2.18.0
27+
pyparsing==3.2.0
28+
pytest==8.3.3
2929
python-dateutil==2.9.0.post0
30-
rich==13.7.1
31-
scipy==1.12.0
30+
rich==13.9.4
31+
scipy==1.14.1
3232
six==1.16.0
3333
sortedcontainers==2.4.0
34-
typing-extensions==4.10.0
34+
typing-extensions==4.12.2

tests/integration/state_sim_tests/test_cointoss.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from __future__ import annotations
1313

1414
import numpy as np
15-
1615
from pecos.circuits import QuantumCircuit
1716
from pecos.simulators import CoinToss
1817

tests/integration/state_sim_tests/test_statevec.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
import numpy as np
2525
import pytest
26-
2726
from pecos.circuits import QuantumCircuit
2827
from pecos.engines.hybrid_engine import HybridEngine
2928
from pecos.error_models.generic_error_model import GenericErrorModel

tests/integration/test_phir.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def is_wasmer_supported():
5454
return WASMER_ERR_MSG != "Wasmer is not available on this system"
5555

5656

57-
@pytest.mark.wasmtime()
58-
@pytest.mark.optional_dependency()
57+
@pytest.mark.wasmtime
58+
@pytest.mark.optional_dependency
5959
def test_spec_example_wasmtime():
6060
"""A random example showing that various basic aspects of PHIR is runnable by PECOS."""
6161

@@ -67,8 +67,8 @@ def test_spec_example_wasmtime():
6767
)
6868

6969

70-
@pytest.mark.wasmtime()
71-
@pytest.mark.optional_dependency()
70+
@pytest.mark.wasmtime
71+
@pytest.mark.optional_dependency
7272
def test_spec_example_noisy_wasmtime():
7373
"""A random example showing that various basic aspects of PHIR is runnable by PECOS, with noise."""
7474

@@ -95,8 +95,8 @@ def test_spec_example_noisy_wasmtime():
9595
)
9696

9797

98-
@pytest.mark.wasmtime()
99-
@pytest.mark.optional_dependency()
98+
@pytest.mark.wasmtime
99+
@pytest.mark.optional_dependency
100100
def test_example1_wasmtime():
101101
"""A random example showing that various basic aspects of PHIR is runnable by PECOS."""
102102

@@ -108,8 +108,8 @@ def test_example1_wasmtime():
108108
)
109109

110110

111-
@pytest.mark.wasmtime()
112-
@pytest.mark.optional_dependency()
111+
@pytest.mark.wasmtime
112+
@pytest.mark.optional_dependency
113113
def test_example1_noisy_wasmtime():
114114
"""A random example showing that various basic aspects of PHIR is runnable by PECOS, with noise."""
115115

@@ -137,8 +137,8 @@ def test_example1_noisy_wasmtime():
137137

138138

139139
@pytest.mark.skipif(not is_wasmer_supported(), reason="Wasmer is not support on some OS/Python version combinations.")
140-
@pytest.mark.wasmer()
141-
@pytest.mark.optional_dependency()
140+
@pytest.mark.wasmer
141+
@pytest.mark.optional_dependency
142142
def test_example1_wasmer():
143143
"""A random example showing that various basic aspects of PHIR is runnable by PECOS."""
144144

@@ -151,8 +151,8 @@ def test_example1_wasmer():
151151

152152

153153
@pytest.mark.skipif(not is_wasmer_supported(), reason="Wasmer is not support on some OS/Python version combinations.")
154-
@pytest.mark.wasmer()
155-
@pytest.mark.optional_dependency()
154+
@pytest.mark.wasmer
155+
@pytest.mark.optional_dependency
156156
def test_example1_noisy_wasmer():
157157
"""A random example showing that various basic aspects of PHIR is runnable by PECOS, with noise."""
158158

@@ -260,7 +260,7 @@ def test_qparallel():
260260
assert m.count("1111") == len(m)
261261

262262

263-
@pytest.mark.optional_dependency() # uses projectq / state-vector
263+
@pytest.mark.optional_dependency # uses projectq / state-vector
264264
def test_bell_qparallel():
265265
"""Testing a program creating and measuring a Bell state and using qparallel blocks returns expected results."""
266266

tests/regression/test_qasm/conftest.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
import pytest
66

77

8-
@pytest.fixture()
8+
@pytest.fixture
99
def compare_qasm():
10-
def _compare_qasm(block, *params, directory: Path | None = None, filename: str | None = None):
11-
10+
def _compare_qasm(
11+
block,
12+
*params,
13+
directory: Path | None = None,
14+
filename: str | None = None,
15+
):
1216
if directory is None:
1317
directory = Path(__file__).parent
1418

@@ -28,10 +32,13 @@ def _compare_qasm(block, *params, directory: Path | None = None, filename: str |
2832

2933
qasm1 = qasm1.strip()
3034

31-
if hasattr(block, "gen"):
35+
# TODO: Fix this... this is kinda hacky
36+
if hasattr(block, "qargs") and hasattr(block, "params") and hasattr(block, "sym"):
3237
qasm2 = block.gen("qasm").strip()
38+
elif hasattr(block, "gen"):
39+
qasm2 = block.gen("qasm", add_versions=False).strip()
3340
else:
34-
qasm2 = block.qasm().strip()
41+
qasm2 = block.qasm(add_versions=False).strip()
3542

3643
assert qasm1 == qasm2
3744

0 commit comments

Comments
 (0)