sinter 1.15.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of sinter might be problematic. Click here for more details.

Files changed (62) hide show
  1. sinter/__init__.py +47 -0
  2. sinter/_collection/__init__.py +10 -0
  3. sinter/_collection/_collection.py +480 -0
  4. sinter/_collection/_collection_manager.py +581 -0
  5. sinter/_collection/_collection_manager_test.py +287 -0
  6. sinter/_collection/_collection_test.py +317 -0
  7. sinter/_collection/_collection_worker_loop.py +35 -0
  8. sinter/_collection/_collection_worker_state.py +259 -0
  9. sinter/_collection/_collection_worker_test.py +222 -0
  10. sinter/_collection/_mux_sampler.py +56 -0
  11. sinter/_collection/_printer.py +65 -0
  12. sinter/_collection/_sampler_ramp_throttled.py +66 -0
  13. sinter/_collection/_sampler_ramp_throttled_test.py +144 -0
  14. sinter/_command/__init__.py +0 -0
  15. sinter/_command/_main.py +39 -0
  16. sinter/_command/_main_collect.py +350 -0
  17. sinter/_command/_main_collect_test.py +482 -0
  18. sinter/_command/_main_combine.py +84 -0
  19. sinter/_command/_main_combine_test.py +153 -0
  20. sinter/_command/_main_plot.py +817 -0
  21. sinter/_command/_main_plot_test.py +445 -0
  22. sinter/_command/_main_predict.py +75 -0
  23. sinter/_command/_main_predict_test.py +36 -0
  24. sinter/_data/__init__.py +20 -0
  25. sinter/_data/_anon_task_stats.py +89 -0
  26. sinter/_data/_anon_task_stats_test.py +35 -0
  27. sinter/_data/_collection_options.py +106 -0
  28. sinter/_data/_collection_options_test.py +24 -0
  29. sinter/_data/_csv_out.py +74 -0
  30. sinter/_data/_existing_data.py +173 -0
  31. sinter/_data/_existing_data_test.py +41 -0
  32. sinter/_data/_task.py +311 -0
  33. sinter/_data/_task_stats.py +244 -0
  34. sinter/_data/_task_stats_test.py +140 -0
  35. sinter/_data/_task_test.py +38 -0
  36. sinter/_decoding/__init__.py +16 -0
  37. sinter/_decoding/_decoding.py +419 -0
  38. sinter/_decoding/_decoding_all_built_in_decoders.py +25 -0
  39. sinter/_decoding/_decoding_decoder_class.py +161 -0
  40. sinter/_decoding/_decoding_fusion_blossom.py +193 -0
  41. sinter/_decoding/_decoding_mwpf.py +302 -0
  42. sinter/_decoding/_decoding_pymatching.py +81 -0
  43. sinter/_decoding/_decoding_test.py +480 -0
  44. sinter/_decoding/_decoding_vacuous.py +38 -0
  45. sinter/_decoding/_perfectionist_sampler.py +38 -0
  46. sinter/_decoding/_sampler.py +72 -0
  47. sinter/_decoding/_stim_then_decode_sampler.py +222 -0
  48. sinter/_decoding/_stim_then_decode_sampler_test.py +192 -0
  49. sinter/_plotting.py +619 -0
  50. sinter/_plotting_test.py +108 -0
  51. sinter/_predict.py +381 -0
  52. sinter/_predict_test.py +227 -0
  53. sinter/_probability_util.py +519 -0
  54. sinter/_probability_util_test.py +281 -0
  55. sinter-1.15.0.data/data/README.md +332 -0
  56. sinter-1.15.0.data/data/readme_example_plot.png +0 -0
  57. sinter-1.15.0.data/data/requirements.txt +4 -0
  58. sinter-1.15.0.dist-info/METADATA +354 -0
  59. sinter-1.15.0.dist-info/RECORD +62 -0
  60. sinter-1.15.0.dist-info/WHEEL +5 -0
  61. sinter-1.15.0.dist-info/entry_points.txt +2 -0
  62. sinter-1.15.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,153 @@
1
+ import contextlib
2
+ import io
3
+ import pathlib
4
+ import tempfile
5
+
6
+ from sinter._command._main import main
7
+
8
+
9
+ def test_main_combine():
10
+ with tempfile.TemporaryDirectory() as d:
11
+ d = pathlib.Path(d)
12
+ with open(d / f'input.csv', 'w') as f:
13
+ print("""
14
+ shots,errors,discards,seconds,decoder,strong_id,json_metadata
15
+ 300,1,20,1.0,pymatching,f256bab362f516ebe4d59a08ae67330ff7771ff738757cd738f4b30605ddccf6,"{""path"":""a.stim""}"
16
+ 300,100,200,2.0,pymatching,f256bab362f516ebe4d59a08ae67330ff7771ff738757cd738f4b30605ddccf6,"{""path"":""a.stim""}"
17
+ 9,5,4,6.0,pymatching,5fe5a6cd4226b1a910d57e5479d1ba6572e0b3115983c9516360916d1670000f,"{""path"":""b.stim""}"
18
+ """.strip(), file=f)
19
+
20
+ out = io.StringIO()
21
+ with contextlib.redirect_stdout(out):
22
+ main(command_line_args=[
23
+ "combine",
24
+ str(d / "input.csv"),
25
+ ])
26
+ assert out.getvalue() == """ shots, errors, discards, seconds,decoder,strong_id,json_metadata,custom_counts
27
+ 600, 101, 220, 3.00,pymatching,f256bab362f516ebe4d59a08ae67330ff7771ff738757cd738f4b30605ddccf6,"{""path"":""a.stim""}",
28
+ 9, 5, 4, 6.00,pymatching,5fe5a6cd4226b1a910d57e5479d1ba6572e0b3115983c9516360916d1670000f,"{""path"":""b.stim""}",
29
+ """
30
+
31
+ out = io.StringIO()
32
+ with contextlib.redirect_stdout(out):
33
+ main(command_line_args=[
34
+ "combine",
35
+ str(d / "input.csv"),
36
+ str(d / "input.csv"),
37
+ ])
38
+ assert out.getvalue() == """ shots, errors, discards, seconds,decoder,strong_id,json_metadata,custom_counts
39
+ 1200, 202, 440, 6.00,pymatching,f256bab362f516ebe4d59a08ae67330ff7771ff738757cd738f4b30605ddccf6,"{""path"":""a.stim""}",
40
+ 18, 10, 8, 12.0,pymatching,5fe5a6cd4226b1a910d57e5479d1ba6572e0b3115983c9516360916d1670000f,"{""path"":""b.stim""}",
41
+ """
42
+
43
+
44
+ def test_main_combine_legacy_custom_counts():
45
+ with tempfile.TemporaryDirectory() as d:
46
+ d = pathlib.Path(d)
47
+ with open(d / f'old.csv', 'w') as f:
48
+ print("""
49
+ shots,errors,discards,seconds,decoder,strong_id,json_metadata
50
+ 100,1,20,1.0,pymatching,abc123,"{""path"":""a.stim""}"
51
+ """.strip(), file=f)
52
+ with open(d / f'new.csv', 'w') as f:
53
+ print("""
54
+ shots,errors,discards,seconds,decoder,strong_id,json_metadata,custom_counts
55
+ 300,1,20,1.0,pymatching,abc123,"{""path"":""a.stim""}","{""x"":2}"
56
+ 300,1,20,1.0,pymatching,abc123,"{""path"":""a.stim""}","{""y"":3}"
57
+ """.strip(), file=f)
58
+
59
+ out = io.StringIO()
60
+ with contextlib.redirect_stdout(out):
61
+ main(command_line_args=[
62
+ "combine",
63
+ str(d / "old.csv"),
64
+ str(d / "new.csv"),
65
+ ])
66
+ assert out.getvalue() == """ shots, errors, discards, seconds,decoder,strong_id,json_metadata,custom_counts
67
+ 700, 3, 60, 3.00,pymatching,abc123,"{""path"":""a.stim""}","{""x"":2,""y"":3}"
68
+ """
69
+
70
+
71
+ def test_order_flag():
72
+ with tempfile.TemporaryDirectory() as d:
73
+ d = pathlib.Path(d)
74
+ with open(d / f'input.csv', 'w') as f:
75
+ print("""
76
+ shots,errors,discards,seconds,decoder, strong_id,json_metadata
77
+ 1000, 100, 4, 2.0, pymatching,deadbeef0,"{""d"":19}"
78
+ 2000, 300, 3, 3.0, pymatching,deadbeef1,"{""d"":9}"
79
+ 3000, 200, 2000, 5.0, pymatching,deadbeef2,"{""d"":200}"
80
+ 4000, 100, 1, 7.0, pymatching,deadbeef3,"{""d"":3}"
81
+ 5000, 100, 0, 11, pymatching,deadbeef4,"{""d"":5}"
82
+ """.strip(), file=f)
83
+
84
+ out = io.StringIO()
85
+ with contextlib.redirect_stdout(out):
86
+ main(command_line_args=[
87
+ "combine",
88
+ "--order",
89
+ "preserve",
90
+ str(d / "input.csv"),
91
+ str(d / "input.csv"),
92
+ ])
93
+ assert out.getvalue() == """ shots, errors, discards, seconds,decoder,strong_id,json_metadata,custom_counts
94
+ 2000, 200, 8, 4.00,pymatching,deadbeef0,"{""d"":19}",
95
+ 4000, 600, 6, 6.00,pymatching,deadbeef1,"{""d"":9}",
96
+ 6000, 400, 4000, 10.0,pymatching,deadbeef2,"{""d"":200}",
97
+ 8000, 200, 2, 14.0,pymatching,deadbeef3,"{""d"":3}",
98
+ 10000, 200, 0, 22.0,pymatching,deadbeef4,"{""d"":5}",
99
+ """
100
+
101
+ out = io.StringIO()
102
+ with contextlib.redirect_stdout(out):
103
+ main(command_line_args=[
104
+ "combine",
105
+ "--order",
106
+ "metadata",
107
+ str(d / "input.csv"),
108
+ str(d / "input.csv"),
109
+ ])
110
+ assert out.getvalue() == """ shots, errors, discards, seconds,decoder,strong_id,json_metadata,custom_counts
111
+ 8000, 200, 2, 14.0,pymatching,deadbeef3,"{""d"":3}",
112
+ 10000, 200, 0, 22.0,pymatching,deadbeef4,"{""d"":5}",
113
+ 4000, 600, 6, 6.00,pymatching,deadbeef1,"{""d"":9}",
114
+ 2000, 200, 8, 4.00,pymatching,deadbeef0,"{""d"":19}",
115
+ 6000, 400, 4000, 10.0,pymatching,deadbeef2,"{""d"":200}",
116
+ """
117
+
118
+ out = io.StringIO()
119
+ with contextlib.redirect_stdout(out):
120
+ main(command_line_args=[
121
+ "combine",
122
+ "--order",
123
+ "error",
124
+ str(d / "input.csv"),
125
+ str(d / "input.csv"),
126
+ ])
127
+ assert out.getvalue() == """ shots, errors, discards, seconds,decoder,strong_id,json_metadata,custom_counts
128
+ 10000, 200, 0, 22.0,pymatching,deadbeef4,"{""d"":5}",
129
+ 8000, 200, 2, 14.0,pymatching,deadbeef3,"{""d"":3}",
130
+ 2000, 200, 8, 4.00,pymatching,deadbeef0,"{""d"":19}",
131
+ 4000, 600, 6, 6.00,pymatching,deadbeef1,"{""d"":9}",
132
+ 6000, 400, 4000, 10.0,pymatching,deadbeef2,"{""d"":200}",
133
+ """
134
+
135
+
136
+ def test_order_custom_counts():
137
+ with tempfile.TemporaryDirectory() as d:
138
+ d = pathlib.Path(d)
139
+ with open(d / f'input.csv', 'w') as f:
140
+ print("""
141
+ shots,errors,discards,seconds,decoder, strong_id,json_metadata,custom_counts
142
+ 1000, 100, 4, 2.0, pymatching,deadbeef0,[],"{""d4"":3,""d2"":30}"
143
+ """.strip(), file=f)
144
+
145
+ out = io.StringIO()
146
+ with contextlib.redirect_stdout(out):
147
+ main(command_line_args=[
148
+ "combine",
149
+ str(d / "input.csv"),
150
+ ])
151
+ assert out.getvalue() == """ shots, errors, discards, seconds,decoder,strong_id,json_metadata,custom_counts
152
+ 1000, 100, 4, 2.00,pymatching,deadbeef0,[],"{""d2"":30,""d4"":3}"
153
+ """