cirq-core 1.4.0.dev20240119190122__py3-none-any.whl → 1.4.0.dev20240202011834__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 cirq-core might be problematic. Click here for more details.

cirq/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.4.0.dev20240119190122"
1
+ __version__ = "1.4.0.dev20240202011834"
@@ -18,6 +18,10 @@ from typing import Any, Dict, Iterable, List, Optional, TYPE_CHECKING
18
18
 
19
19
  import sympy
20
20
  import numpy as np
21
+ import matplotlib.pyplot as plt
22
+ import cirq.vis.heatmap as cirq_heatmap
23
+ import cirq.vis.histogram as cirq_histogram
24
+ from cirq.devices import grid_qubit
21
25
  from cirq import circuits, ops, study
22
26
 
23
27
  if TYPE_CHECKING:
@@ -51,6 +55,124 @@ class SingleQubitReadoutCalibrationResult:
51
55
  'timestamp': self.timestamp,
52
56
  }
53
57
 
58
+ def plot_heatmap(
59
+ self,
60
+ axs: Optional[tuple[plt.Axes, plt.Axes]] = None,
61
+ annotation_format: str = '0.1%',
62
+ **plot_kwargs: Any,
63
+ ) -> tuple[plt.Axes, plt.Axes]:
64
+ """Plot a heatmap of the readout errors. If qubits are not cirq.GridQubits, throws an error.
65
+
66
+ Args:
67
+ axs: a tuple of the plt.Axes to plot on. If not given, a new figure is created,
68
+ plotted on, and shown.
69
+ annotation_format: The format string for the numbers in the heatmap.
70
+ **plot_kwargs: Arguments to be passed to 'cirq.Heatmap.plot()'.
71
+ Returns:
72
+ The two plt.Axes containing the plot.
73
+
74
+ Raises:
75
+ ValueError: axs does not contain two plt.Axes
76
+ TypeError: qubits are not cirq.GridQubits
77
+ """
78
+
79
+ if axs is None:
80
+ _, axs = plt.subplots(1, 2, dpi=200, facecolor='white', figsize=(12, 4))
81
+
82
+ else:
83
+ if (
84
+ not isinstance(axs, (tuple, list, np.ndarray))
85
+ or len(axs) != 2
86
+ or type(axs[0]) != plt.Axes
87
+ or type(axs[1]) != plt.Axes
88
+ ): # pragma: no cover
89
+ raise ValueError('axs should be a length-2 tuple of plt.Axes') # pragma: no cover
90
+ for ax, title, data in zip(
91
+ axs,
92
+ ['$|0\\rangle$ errors', '$|1\\rangle$ errors'],
93
+ [self.zero_state_errors, self.one_state_errors],
94
+ ):
95
+ data_with_grid_qubit_keys = {}
96
+ for qubit in data:
97
+ if type(qubit) != grid_qubit.GridQubit:
98
+ raise TypeError(f'{qubit} must be of type cirq.GridQubit') # pragma: no cover
99
+ data_with_grid_qubit_keys[qubit] = data[qubit] # just for typecheck
100
+ _, _ = cirq_heatmap.Heatmap(data_with_grid_qubit_keys).plot(
101
+ ax, annotation_format=annotation_format, title=title, **plot_kwargs
102
+ )
103
+ return axs[0], axs[1]
104
+
105
+ def plot_integrated_histogram(
106
+ self,
107
+ ax: Optional[plt.Axes] = None,
108
+ cdf_on_x: bool = False,
109
+ axis_label: str = 'Readout error rate',
110
+ semilog: bool = True,
111
+ median_line: bool = True,
112
+ median_label: Optional[str] = 'median',
113
+ mean_line: bool = False,
114
+ mean_label: Optional[str] = 'mean',
115
+ show_zero: bool = False,
116
+ title: Optional[str] = None,
117
+ **kwargs,
118
+ ) -> plt.Axes:
119
+ """Plot the readout errors using cirq.integrated_histogram().
120
+
121
+ Args:
122
+ ax: The axis to plot on. If None, we generate one.
123
+ cdf_on_x: If True, flip the axes compared the above example.
124
+ axis_label: Label for x axis (y-axis if cdf_on_x is True).
125
+ semilog: If True, force the x-axis to be logarithmic.
126
+ median_line: If True, draw a vertical line on the median value.
127
+ median_label: If drawing median line, optional label for it.
128
+ mean_line: If True, draw a vertical line on the mean value.
129
+ mean_label: If drawing mean line, optional label for it.
130
+ title: Title of the plot. If None, we assign "N={len(data)}".
131
+ show_zero: If True, moves the step plot up by one unit by prepending 0
132
+ to the data.
133
+ **kwargs: Kwargs to forward to `ax.step()`. Some examples are
134
+ color: Color of the line.
135
+ linestyle: Linestyle to use for the plot.
136
+ lw: linewidth for integrated histogram.
137
+ ms: marker size for a histogram trace.
138
+ Returns:
139
+ The axis that was plotted on.
140
+ """
141
+
142
+ ax = cirq_histogram.integrated_histogram(
143
+ data=self.zero_state_errors,
144
+ ax=ax,
145
+ cdf_on_x=cdf_on_x,
146
+ semilog=semilog,
147
+ median_line=median_line,
148
+ median_label=median_label,
149
+ mean_line=mean_line,
150
+ mean_label=mean_label,
151
+ show_zero=show_zero,
152
+ color='C0',
153
+ label='$|0\\rangle$ errors',
154
+ **kwargs,
155
+ )
156
+ ax = cirq_histogram.integrated_histogram(
157
+ data=self.one_state_errors,
158
+ ax=ax,
159
+ cdf_on_x=cdf_on_x,
160
+ axis_label=axis_label,
161
+ semilog=semilog,
162
+ median_line=median_line,
163
+ median_label=median_label,
164
+ mean_line=mean_line,
165
+ mean_label=mean_label,
166
+ show_zero=show_zero,
167
+ title=title,
168
+ color='C1',
169
+ label='$|1\\rangle$ errors',
170
+ **kwargs,
171
+ )
172
+ ax.legend(loc='best')
173
+ ax.set_ylabel('Percentile')
174
+ return ax
175
+
54
176
  @classmethod
55
177
  def _from_json_dict_(
56
178
  cls, zero_state_errors, one_state_errors, repetitions, timestamp, **kwargs
@@ -87,7 +87,7 @@ def test_estimate_single_qubit_readout_errors_with_noise():
87
87
 
88
88
 
89
89
  def test_estimate_parallel_readout_errors_no_noise():
90
- qubits = cirq.LineQubit.range(10)
90
+ qubits = [cirq.GridQubit(i, 0) for i in range(10)]
91
91
  sampler = cirq.Simulator()
92
92
  repetitions = 1000
93
93
  result = cirq.estimate_parallel_single_qubit_readout_errors(
@@ -97,6 +97,8 @@ def test_estimate_parallel_readout_errors_no_noise():
97
97
  assert result.one_state_errors == {q: 0 for q in qubits}
98
98
  assert result.repetitions == repetitions
99
99
  assert isinstance(result.timestamp, float)
100
+ _ = result.plot_integrated_histogram()
101
+ _, _ = result.plot_heatmap()
100
102
 
101
103
 
102
104
  def test_estimate_parallel_readout_errors_all_zeros():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cirq-core
3
- Version: 1.4.0.dev20240119190122
3
+ Version: 1.4.0.dev20240202011834
4
4
  Summary: A framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
5
5
  Home-page: http://github.com/quantumlib/cirq
6
6
  Author: The Cirq Developers
@@ -22,10 +22,10 @@ Requires-Dist: tqdm
22
22
  Provides-Extra: contrib
23
23
  Requires-Dist: ply >=3.6 ; extra == 'contrib'
24
24
  Requires-Dist: pylatex ~=1.3.0 ; extra == 'contrib'
25
- Requires-Dist: quimb ; extra == 'contrib'
25
+ Requires-Dist: quimb ~=1.6.0 ; extra == 'contrib'
26
26
  Requires-Dist: opt-einsum ; extra == 'contrib'
27
27
  Requires-Dist: autoray ; extra == 'contrib'
28
- Requires-Dist: numba >=0.53.0 ; extra == 'contrib'
28
+ Requires-Dist: numba ~=0.58.0 ; extra == 'contrib'
29
29
 
30
30
  **This is a development version of Cirq-core and may be unstable.**
31
31
 
@@ -4,7 +4,7 @@ cirq/_compat_test.py,sha256=Qq3ZcfgD-Nb81cEppQdJqhAyrVqXKtfXZYGXT0p-Wh0,34718
4
4
  cirq/_doc.py,sha256=yDyWUD_2JDS0gShfGRb-rdqRt9-WeL7DhkqX7np0Nko,2879
5
5
  cirq/_import.py,sha256=p9gMHJscbtDDkfHOaulvd3Aer0pwUF5AXpL89XR8dNw,8402
6
6
  cirq/_import_test.py,sha256=6K_v0riZJXOXUphHNkGA8MY-JcmGlezFaGmvrNhm3OQ,1015
7
- cirq/_version.py,sha256=fHQ4y1pxGTu4CFZx0IykevoZ6_MyMssLXp957XAHRNo,40
7
+ cirq/_version.py,sha256=w9W2FfGo5T_I8T8mgkJx_01_bNCqdNTOnegeBXc16pU,40
8
8
  cirq/_version_test.py,sha256=yYS6xm5-nuBRQJa9R3n41WdvFtVyY7Lb5Q8bea3VgBI,133
9
9
  cirq/conftest.py,sha256=X7yLFL8GLhg2CjPw0hp5e_dGASfvHx1-QT03aUbhKJw,1168
10
10
  cirq/json_resolver_cache.py,sha256=S0HaPOCUIck-vNSQlS6KxnQtle6w-2dGuSxkUbJQY9Y,13168
@@ -190,8 +190,8 @@ cirq/experiments/random_quantum_circuit_generation.py,sha256=R_w7z35plUHEYBY0-F8
190
190
  cirq/experiments/random_quantum_circuit_generation_test.py,sha256=1rvgN8-Ajedn_70FyYKVzjvzR6NVpHj6KQgo6tra-Jc,15995
191
191
  cirq/experiments/readout_confusion_matrix.py,sha256=gsRjGJTDcxRPtY7G63t-nYoJ1BcByC1jl02zHh2B8fQ,17278
192
192
  cirq/experiments/readout_confusion_matrix_test.py,sha256=R4UoGklVJ2owqeDTRVP4M9gYynzVYgw-Y76VLcoIJtY,6766
193
- cirq/experiments/single_qubit_readout_calibration.py,sha256=F3sFivMhTAkeFPYLnXrHyx8JAIKbH4Lo5RFCsFWNsXM,9725
194
- cirq/experiments/single_qubit_readout_calibration_test.py,sha256=U7roQDUkPvkEkpCX5gx9i4AM3r9p4Fy3JkufGLrfijE,7625
193
+ cirq/experiments/single_qubit_readout_calibration.py,sha256=UerUTo0itB2K68VKfggkKIQfVva4FVbFXqvtydKTsIg,14535
194
+ cirq/experiments/single_qubit_readout_calibration_test.py,sha256=_002QXj2rIFHkH3vw9iTVMh45vCPuCI_fTqOUK8uMe4,7718
195
195
  cirq/experiments/t1_decay_experiment.py,sha256=dQ9DF84im2vIkxCjrbfn5oCQkTajlXIEJU3_iClu9s4,6812
196
196
  cirq/experiments/t1_decay_experiment_test.py,sha256=B2oDyVL0bD5saI_5kh0h70b8mnXvvReavkalrbxdf38,9485
197
197
  cirq/experiments/t2_decay_experiment.py,sha256=lTgZ9yJ7Fk9_ozUCHysQn1qKrMQwTpsgEv-QnvsEif0,19158
@@ -1148,8 +1148,8 @@ cirq/work/sampler.py,sha256=JEAeQQRF3bqlO9AkOf4XbrTATDI5f5JgyM_FAUCNxao,19751
1148
1148
  cirq/work/sampler_test.py,sha256=B2ZsuqGT854gQtBIAh8k0LiG9Vj5wSzcGvkxOUoTcW4,13217
1149
1149
  cirq/work/zeros_sampler.py,sha256=x1C7cup66a43n-3tm8QjhiqJa07qcJW10FxNp9jJ59Q,2356
1150
1150
  cirq/work/zeros_sampler_test.py,sha256=JIkpBBFPJe5Ba4142vzogyWyboG1Q1ZAm0UVGgOoZn8,3279
1151
- cirq_core-1.4.0.dev20240119190122.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1152
- cirq_core-1.4.0.dev20240119190122.dist-info/METADATA,sha256=MylPYYTlqHSpDs9LmO5IGZC0xjdeJjOXnMULthxXXfQ,2075
1153
- cirq_core-1.4.0.dev20240119190122.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
1154
- cirq_core-1.4.0.dev20240119190122.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1155
- cirq_core-1.4.0.dev20240119190122.dist-info/RECORD,,
1151
+ cirq_core-1.4.0.dev20240202011834.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1152
+ cirq_core-1.4.0.dev20240202011834.dist-info/METADATA,sha256=eYQ7QeaJK0RH3S3PTT8rs_LdbfLYRSz9oLQaQQ4ISNw,2083
1153
+ cirq_core-1.4.0.dev20240202011834.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
1154
+ cirq_core-1.4.0.dev20240202011834.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1155
+ cirq_core-1.4.0.dev20240202011834.dist-info/RECORD,,