Skip to content

Commit b374a24

Browse files
authored
Fix *.from_file examples opening a file then not using it (#913)
Fixes #851
1 parent dfb81d3 commit b374a24

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

doc/python_api_reference_vDev.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,7 @@ def from_file(
19621962
... with open(path, 'w') as f:
19631963
... print('CNOT 4 5', file=f)
19641964
... with open(path) as f:
1965-
... circuit = stim.Circuit.from_file(path)
1965+
... circuit = stim.Circuit.from_file(f)
19661966
>>> circuit
19671967
stim.Circuit('''
19681968
CX 4 5
@@ -7292,7 +7292,7 @@ def from_file(
72927292
... with open(path, 'w') as f:
72937293
... print('error(0.25) D2 D3', file=f)
72947294
... with open(path) as f:
7295-
... circuit = stim.DetectorErrorModel.from_file(path)
7295+
... circuit = stim.DetectorErrorModel.from_file(f)
72967296
>>> circuit
72977297
stim.DetectorErrorModel('''
72987298
error(0.25) D2 D3

doc/stim.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ class Circuit:
13501350
... with open(path, 'w') as f:
13511351
... print('CNOT 4 5', file=f)
13521352
... with open(path) as f:
1353-
... circuit = stim.Circuit.from_file(path)
1353+
... circuit = stim.Circuit.from_file(f)
13541354
>>> circuit
13551355
stim.Circuit('''
13561356
CX 4 5
@@ -5714,7 +5714,7 @@ class DetectorErrorModel:
57145714
... with open(path, 'w') as f:
57155715
... print('error(0.25) D2 D3', file=f)
57165716
... with open(path) as f:
5717-
... circuit = stim.DetectorErrorModel.from_file(path)
5717+
... circuit = stim.DetectorErrorModel.from_file(f)
57185718
>>> circuit
57195719
stim.DetectorErrorModel('''
57205720
error(0.25) D2 D3

glue/python/src/stim/__init__.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ class Circuit:
13501350
... with open(path, 'w') as f:
13511351
... print('CNOT 4 5', file=f)
13521352
... with open(path) as f:
1353-
... circuit = stim.Circuit.from_file(path)
1353+
... circuit = stim.Circuit.from_file(f)
13541354
>>> circuit
13551355
stim.Circuit('''
13561356
CX 4 5
@@ -5714,7 +5714,7 @@ class DetectorErrorModel:
57145714
... with open(path, 'w') as f:
57155715
... print('error(0.25) D2 D3', file=f)
57165716
... with open(path) as f:
5717-
... circuit = stim.DetectorErrorModel.from_file(path)
5717+
... circuit = stim.DetectorErrorModel.from_file(f)
57185718
>>> circuit
57195719
stim.DetectorErrorModel('''
57205720
error(0.25) D2 D3

src/stim/circuit/circuit.pybind.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,7 @@ void stim_pybind::pybind_circuit_methods(pybind11::module &, pybind11::class_<Ci
14061406
... with open(path, 'w') as f:
14071407
... print('CNOT 4 5', file=f)
14081408
... with open(path) as f:
1409-
... circuit = stim.Circuit.from_file(path)
1409+
... circuit = stim.Circuit.from_file(f)
14101410
>>> circuit
14111411
stim.Circuit('''
14121412
CX 4 5

src/stim/dem/detector_error_model.pybind.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ void stim_pybind::pybind_detector_error_model_methods(
930930
... with open(path, 'w') as f:
931931
... print('error(0.25) D2 D3', file=f)
932932
... with open(path) as f:
933-
... circuit = stim.DetectorErrorModel.from_file(path)
933+
... circuit = stim.DetectorErrorModel.from_file(f)
934934
>>> circuit
935935
stim.DetectorErrorModel('''
936936
error(0.25) D2 D3

0 commit comments

Comments
 (0)