Skip to content

Commit 851585c

Browse files
committed
lint
1 parent 3e137f8 commit 851585c

230 files changed

Lines changed: 1282 additions & 4857 deletions

File tree

Some content is hidden

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

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ repos:
4444
rev: v0.4.6
4545
hooks:
4646
- id: blackdoc
47+
args: [--line-length=120]
4748
additional_dependencies:
4849
- black==25.9.0

README.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,7 @@ def repetition_code() -> None:
6060

6161
# Run 10 shots with 10% depolarizing noise
6262
noise = depolarizing_noise().with_uniform_probability(0.1)
63-
results = (
64-
sim(Guppy(repetition_code))
65-
.qubits(5)
66-
.quantum(state_vector())
67-
.noise(noise)
68-
.seed(42)
69-
.run(10)
70-
)
63+
results = sim(Guppy(repetition_code)).qubits(5).quantum(state_vector()).noise(noise).seed(42).run(10)
7164
print(results["syndrome"])
7265
# [[1, 1], [0, 1], [0, 0], [1, 1], [0, 0], [0, 1], [1, 1], [0, 0], [0, 1], [0, 1]]
7366
```

docs/README.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,7 @@ Simulate a distance-3 repetition code with syndrome extraction using [Guppy](htt
4949

5050
# Run 10 shots with 10% depolarizing noise
5151
noise = depolarizing_noise().with_uniform_probability(0.1)
52-
results = (
53-
sim(Guppy(repetition_code))
54-
.qubits(5)
55-
.quantum(state_vector())
56-
.noise(noise)
57-
.seed(42)
58-
.run(10)
59-
)
52+
results = sim(Guppy(repetition_code)).qubits(5).quantum(state_vector()).noise(noise).seed(42).run(10)
6053

6154
# Extract syndromes from first two measured qubits (s0, s1)
6255
d = results.to_dict()

docs/development/proposals/slr-ast.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -776,9 +776,7 @@ class ASTStateValidator(BaseVisitor[None]):
776776
def visit_gate(self, node: GateOp) -> None:
777777
# Validate all targets are prepared
778778
for target in node.targets:
779-
state = self.slot_states.get(
780-
(target.allocator, target.index), SlotState.UNPREPARED
781-
)
779+
state = self.slot_states.get((target.allocator, target.index), SlotState.UNPREPARED)
782780
if state == SlotState.UNPREPARED:
783781
self.violations.append(StateViolation(...))
784782

docs/user-guide/getting-started.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,7 @@ A repetition code encodes a single logical qubit across multiple physical qubits
103103

104104
# Run 10 shots with 10% depolarizing noise
105105
noise = depolarizing_noise().with_uniform_probability(0.1)
106-
results = (
107-
sim(Guppy(repetition_code))
108-
.qubits(5)
109-
.quantum(state_vector())
110-
.noise(noise)
111-
.seed(42)
112-
.run(10)
113-
)
106+
results = sim(Guppy(repetition_code)).qubits(5).quantum(state_vector()).noise(noise).seed(42).run(10)
114107

115108
# Extract syndromes from first two measured qubits (s0, s1)
116109
d = results.to_dict()

docs/user-guide/graph-api.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,7 @@ The graph itself can store metadata as attributes.
206206
graph.attrs().insert("version", "1.0").insert("author", "Alice")
207207

208208
# Style 3: Batch update
209-
graph.attrs().update(
210-
{"date": "2025-01-26", "tags": ["qec", "surface_code"], "validated": True}
211-
)
209+
graph.attrs().update({"date": "2025-01-26", "tags": ["qec", "surface_code"], "validated": True})
212210
```
213211

214212
=== ":fontawesome-brands-rust: Rust"

docs/user-guide/hugr-simulation.md

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ Let's create a Bell state using Guppy. First, define a quantum function:
5656

5757

5858
# Run simulation
59-
results = (
60-
sim(Guppy(bell_state)).qubits(2).quantum(state_vector()).seed(42).run(1000)
61-
)
59+
results = sim(Guppy(bell_state)).qubits(2).quantum(state_vector()).seed(42).run(1000)
6260

6361
print(results.to_dict())
6462
# Results: always correlated (00 or 11)
@@ -157,12 +155,7 @@ If you have HUGR files (compiled from Guppy or other tools), you can run them di
157155
from pecos_rslib import state_vector
158156

159157
# From file
160-
results = (
161-
sim(Hugr.from_file("/tmp/pecos-doc-tests/circuit.hugr"))
162-
.qubits(2)
163-
.quantum(state_vector())
164-
.run(1000)
165-
)
158+
results = sim(Hugr.from_file("/tmp/pecos-doc-tests/circuit.hugr")).qubits(2).quantum(state_vector()).run(1000)
166159

167160
# Or from bytes
168161
with open("/tmp/pecos-doc-tests/circuit.hugr", "rb") as f:
@@ -224,9 +217,7 @@ One of HUGR's key advantages is native support for control flow based on measure
224217

225218

226219
# Run simulation
227-
results = (
228-
sim(Guppy(conditional_x)).qubits(2).quantum(state_vector()).seed(42).run(1000)
229-
)
220+
results = sim(Guppy(conditional_x)).qubits(2).quantum(state_vector()).seed(42).run(1000)
230221

231222
# Results: m0 and m1 are always equal!
232223
# - If m0=0: no X applied, m1=0
@@ -262,9 +253,7 @@ One of HUGR's key advantages is native support for control flow based on measure
262253
return m0, m1
263254

264255

265-
results = (
266-
sim(Guppy(if_else_circuit)).qubits(2).quantum(state_vector()).seed(42).run(1000)
267-
)
256+
results = sim(Guppy(if_else_circuit)).qubits(2).quantum(state_vector()).seed(42).run(1000)
268257
# m0 always 0, m1 is 50/50 (H applied)
269258
```
270259

@@ -408,9 +397,7 @@ Add realistic noise to your Guppy simulations:
408397
.with_meas_1_probability(0.03)
409398
)
410399

411-
results = (
412-
sim(Guppy(noisy_bell)).qubits(2).quantum(state_vector()).noise(noise).run(1000)
413-
)
400+
results = sim(Guppy(noisy_bell)).qubits(2).quantum(state_vector()).noise(noise).run(1000)
414401
```
415402

416403
## HUGR vs QASM: When to Use Each

docs/user-guide/noise-model-builders.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ noise = (
6969

7070
# Total probability (used internally by the engine)
7171
noise = (
72-
GeneralNoiseModelBuilder()
73-
.with_p1_probability(0.00133) # Total for single-qubit
74-
.with_p2_probability(0.0133)
72+
GeneralNoiseModelBuilder().with_p1_probability(0.00133).with_p2_probability(0.0133) # Total for single-qubit
7573
) # Total for two-qubit
7674
```
7775

docs/user-guide/qasm-simulation.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,7 @@ lets you build the experiment once and rerun it multiple times:
178178
"""
179179

180180
# Build once, run multiple times
181-
experiment = (
182-
sim(Qasm(qasm_code))
183-
.seed(42)
184-
.noise(depolarizing_noise().with_uniform_probability(0.01))
185-
.build()
186-
)
181+
experiment = sim(Qasm(qasm_code)).seed(42).noise(depolarizing_noise().with_uniform_probability(0.01)).build()
187182

188183
# Run with different shot counts
189184
results_100 = experiment.run(100)
@@ -461,11 +456,7 @@ This example shows how noise affects quantum entanglement:
461456

462457
# Build simulation with depolarizing noise
463458
experiment = (
464-
sim(Qasm(qasm_code))
465-
.seed(42)
466-
.workers(4)
467-
.noise(depolarizing_noise().with_uniform_probability(0.01))
468-
.build()
459+
sim(Qasm(qasm_code)).seed(42).workers(4).noise(depolarizing_noise().with_uniform_probability(0.01)).build()
469460
)
470461

471462
# Run multiple times

docs/user-guide/qec-geometry.md

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,10 @@ Surface codes are the most widely studied topological QEC codes. PECOS supports
5959
```python
6060
from pecos.qec.surface import SurfacePatchBuilder, PatchOrientation
6161

62-
patch = (
63-
SurfacePatchBuilder()
64-
.with_distance(5)
65-
.with_orientation(PatchOrientation.Z_TOP_BOTTOM)
66-
.build()
67-
)
62+
patch = SurfacePatchBuilder().with_distance(5).with_orientation(PatchOrientation.Z_TOP_BOTTOM).build()
6863

6964
# Non-rotated (standard) layout
70-
patch = (
71-
SurfacePatchBuilder()
72-
.with_distance(5)
73-
.standard() # Use standard layout instead of rotated
74-
.build()
75-
)
65+
patch = SurfacePatchBuilder().with_distance(5).standard().build() # Use standard layout instead of rotated
7666
```
7767

7868
### Accessing Geometry
@@ -91,9 +81,7 @@ print(f"Total qubits: {patch.num_qubits}") # 11 (9 data + 2 ancilla)
9181

9282
# Stabilizers
9383
for stab in patch.x_stabilizers:
94-
print(
95-
f"X stab {stab.index}: qubits={stab.data_qubits}, boundary={stab.is_boundary}"
96-
)
84+
print(f"X stab {stab.index}: qubits={stab.data_qubits}, boundary={stab.is_boundary}")
9785

9886
for stab in patch.z_stabilizers:
9987
print(f"Z stab {stab.index}: qubits={stab.data_qubits}, weight={stab.weight}")
@@ -184,9 +172,7 @@ print(f"Stabilizers: {code.num_stabilizers}")
184172

185173
# All stabilizers
186174
for stab in code.stabilizers:
187-
print(
188-
f"Stab {stab.index}: color={stab.color}, qubits={stab.qubits}, weight={stab.weight}"
189-
)
175+
print(f"Stab {stab.index}: color={stab.color}, qubits={stab.qubits}, weight={stab.weight}")
190176

191177
# Filter by color
192178
red_stabs = code.get_red_stabilizers()

0 commit comments

Comments
 (0)