cirq-core 1.2.0.dev20230717225858__py3-none-any.whl → 1.3.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.
- cirq/__init__.py +5 -0
- cirq/_compat.py +26 -11
- cirq/_compat_test.py +37 -3
- cirq/_version.py +31 -1
- cirq/_version_test.py +1 -1
- cirq/circuits/circuit.py +106 -32
- cirq/circuits/circuit_operation.py +2 -2
- cirq/circuits/circuit_operation_test.py +1 -1
- cirq/circuits/circuit_test.py +109 -3
- cirq/circuits/frozen_circuit.py +80 -5
- cirq/circuits/frozen_circuit_test.py +47 -2
- cirq/circuits/qasm_output_test.py +9 -9
- cirq/conftest.py +1 -2
- cirq/contrib/acquaintance/devices.py +1 -1
- cirq/contrib/hacks/disable_validation_test.py +1 -1
- cirq/contrib/noise_models/noise_models.py +1 -2
- cirq/contrib/paulistring/clifford_optimize.py +1 -1
- cirq/contrib/paulistring/clifford_target_gateset_test.py +4 -4
- cirq/contrib/qcircuit/qcircuit_pdf.py +1 -1
- cirq/contrib/quimb/density_matrix.py +2 -3
- cirq/contrib/quimb/grid_circuits.py +3 -3
- cirq/contrib/quimb/state_vector.py +3 -5
- cirq/contrib/routing/utils.py +1 -2
- cirq/contrib/svg/svg.py +4 -6
- cirq/devices/grid_qubit.py +49 -38
- cirq/devices/grid_qubit_test.py +1 -3
- cirq/devices/insertion_noise_model.py +21 -1
- cirq/devices/insertion_noise_model_test.py +6 -0
- cirq/devices/line_qubit.py +67 -40
- cirq/devices/named_topologies.py +8 -14
- cirq/devices/noise_properties.py +1 -1
- cirq/devices/noise_utils.py +7 -5
- cirq/devices/noise_utils_test.py +7 -0
- cirq/experiments/fidelity_estimation_test.py +1 -1
- cirq/experiments/qubit_characterizations.py +6 -5
- cirq/experiments/random_quantum_circuit_generation.py +1 -1
- cirq/experiments/random_quantum_circuit_generation_test.py +28 -1
- cirq/experiments/readout_confusion_matrix.py +6 -6
- cirq/experiments/xeb_fitting.py +3 -5
- cirq/experiments/xeb_fitting_test.py +2 -2
- cirq/experiments/xeb_sampling.py +1 -1
- cirq/interop/quirk/url_to_circuit.py +40 -38
- cirq/json_resolver_cache.py +2 -0
- cirq/linalg/decompositions.py +6 -5
- cirq/ops/__init__.py +2 -0
- cirq/ops/classically_controlled_operation.py +1 -1
- cirq/ops/clifford_gate.py +9 -9
- cirq/ops/clifford_gate_test.py +3 -4
- cirq/ops/common_channels.py +2 -5
- cirq/ops/common_channels_test.py +3 -5
- cirq/ops/common_gates_test.py +7 -7
- cirq/ops/controlled_operation_test.py +2 -2
- cirq/ops/dense_pauli_string.py +3 -0
- cirq/ops/eigen_gate_test.py +1 -3
- cirq/ops/fourier_transform.py +1 -2
- cirq/ops/fsim_gate.py +1 -1
- cirq/ops/gate_features_test.py +2 -2
- cirq/ops/gate_operation_test.py +1 -2
- cirq/ops/greedy_qubit_manager.py +86 -0
- cirq/ops/greedy_qubit_manager_test.py +98 -0
- cirq/ops/linear_combinations.py +1 -1
- cirq/ops/named_qubit.py +55 -18
- cirq/ops/parity_gates.py +65 -18
- cirq/ops/parity_gates_test.py +41 -2
- cirq/ops/pauli_gates.py +2 -2
- cirq/ops/pauli_string.py +3 -4
- cirq/ops/pauli_string_raw_types_test.py +3 -3
- cirq/ops/pauli_string_test.py +3 -4
- cirq/ops/random_gate_channel_test.py +3 -3
- cirq/ops/raw_types.py +1 -1
- cirq/ops/raw_types_test.py +5 -5
- cirq/ops/three_qubit_gates.py +12 -8
- cirq/protocols/act_on_protocol_test.py +9 -9
- cirq/protocols/apply_channel_protocol.py +9 -6
- cirq/protocols/apply_unitary_protocol_test.py +1 -1
- cirq/protocols/equal_up_to_global_phase_protocol_test.py +2 -2
- cirq/protocols/has_stabilizer_effect_protocol.py +52 -6
- cirq/protocols/has_stabilizer_effect_protocol_test.py +21 -8
- cirq/protocols/has_unitary_protocol_test.py +1 -3
- cirq/protocols/json_serialization.py +6 -6
- cirq/protocols/json_serialization_test.py +7 -14
- cirq/protocols/json_test_data/InsertionNoiseModel.json +91 -0
- cirq/protocols/json_test_data/InsertionNoiseModel.repr +4 -0
- cirq/protocols/json_test_data/OpIdentifier.json +45 -10
- cirq/protocols/json_test_data/OpIdentifier.repr +7 -1
- cirq/protocols/json_test_data/spec.py +4 -0
- cirq/protocols/measurement_key_protocol_test.py +1 -1
- cirq/protocols/unitary_protocol_test.py +13 -16
- cirq/qis/clifford_tableau.py +7 -8
- cirq/qis/measures.py +1 -1
- cirq/qis/states.py +2 -3
- cirq/sim/__init__.py +2 -0
- cirq/sim/classical_simulator.py +107 -0
- cirq/sim/classical_simulator_test.py +207 -0
- cirq/sim/clifford/clifford_simulator_test.py +7 -7
- cirq/sim/clifford/stabilizer_simulation_state.py +2 -2
- cirq/sim/clifford/stabilizer_state_ch_form.py +7 -7
- cirq/sim/density_matrix_simulation_state.py +19 -4
- cirq/sim/density_matrix_simulator_test.py +5 -13
- cirq/sim/simulation_state_test.py +13 -14
- cirq/sim/simulator_test.py +6 -9
- cirq/sim/state_vector_simulation_state.py +1 -1
- cirq/study/resolver.py +41 -41
- cirq/study/resolver_test.py +13 -12
- cirq/testing/__init__.py +4 -1
- cirq/testing/circuit_compare.py +1 -1
- cirq/testing/circuit_compare_test.py +11 -11
- cirq/testing/consistent_controlled_gate_op.py +15 -1
- cirq/testing/consistent_controlled_gate_op_test.py +12 -3
- cirq/testing/consistent_decomposition.py +0 -1
- cirq/testing/consistent_protocols.py +6 -1
- cirq/testing/consistent_protocols_test.py +5 -10
- cirq/testing/consistent_qasm.py +2 -4
- cirq/testing/consistent_qasm_test.py +2 -3
- cirq/testing/consistent_specified_has_unitary_test.py +1 -3
- cirq/testing/equals_tester.py +1 -1
- cirq/testing/equals_tester_test.py +5 -5
- cirq/testing/equivalent_repr_eval_test.py +1 -3
- cirq/testing/gate_features_test.py +6 -6
- cirq/testing/order_tester_test.py +1 -3
- cirq/testing/random_circuit_test.py +1 -3
- cirq/transformers/__init__.py +3 -0
- cirq/transformers/analytical_decompositions/__init__.py +1 -0
- cirq/transformers/analytical_decompositions/three_qubit_decomposition.py +1 -2
- cirq/transformers/analytical_decompositions/three_qubit_decomposition_test.py +2 -5
- cirq/transformers/analytical_decompositions/two_qubit_state_preparation.py +38 -0
- cirq/transformers/analytical_decompositions/two_qubit_state_preparation_test.py +18 -0
- cirq/transformers/expand_composite_test.py +4 -4
- cirq/transformers/heuristic_decompositions/gate_tabulation_math_utils.py +1 -1
- cirq/transformers/heuristic_decompositions/two_qubit_gate_tabulation.py +1 -2
- cirq/transformers/merge_k_qubit_gates_test.py +2 -2
- cirq/transformers/qubit_management_transformers.py +177 -0
- cirq/transformers/qubit_management_transformers_test.py +250 -0
- cirq/transformers/routing/route_circuit_cqc.py +23 -4
- cirq/transformers/routing/route_circuit_cqc_test.py +42 -0
- cirq/transformers/stratify.py +10 -11
- cirq/transformers/target_gatesets/compilation_target_gateset_test.py +10 -10
- cirq/transformers/target_gatesets/cz_gateset_test.py +8 -10
- cirq/transformers/transformer_primitives.py +138 -28
- cirq/value/abc_alt_test.py +4 -4
- cirq/value/duration.py +68 -37
- cirq/value/duration_test.py +2 -0
- cirq/value/measurement_key_test.py +1 -1
- cirq/value/product_state.py +4 -8
- cirq/value/value_equality_attr.py +12 -5
- cirq/vis/heatmap.py +7 -4
- cirq/vis/heatmap_test.py +14 -4
- cirq/vis/histogram.py +4 -4
- cirq/vis/state_histogram.py +10 -6
- cirq/vis/state_histogram_test.py +2 -0
- cirq/work/observable_measurement_data_test.py +1 -1
- cirq/work/observable_measurement_test.py +2 -2
- cirq/work/zeros_sampler.py +1 -1
- {cirq_core-1.2.0.dev20230717225858.dist-info → cirq_core-1.3.0.dist-info}/METADATA +11 -19
- {cirq_core-1.2.0.dev20230717225858.dist-info → cirq_core-1.3.0.dist-info}/RECORD +158 -150
- {cirq_core-1.2.0.dev20230717225858.dist-info → cirq_core-1.3.0.dist-info}/WHEEL +1 -1
- {cirq_core-1.2.0.dev20230717225858.dist-info → cirq_core-1.3.0.dist-info}/LICENSE +0 -0
- {cirq_core-1.2.0.dev20230717225858.dist-info → cirq_core-1.3.0.dist-info}/top_level.txt +0 -0
cirq/vis/histogram.py
CHANGED
|
@@ -100,9 +100,9 @@ def integrated_histogram(
|
|
|
100
100
|
plot_options.update(kwargs)
|
|
101
101
|
|
|
102
102
|
if cdf_on_x:
|
|
103
|
-
ax.step(bin_values, parameter_values, **plot_options)
|
|
103
|
+
ax.step(bin_values, parameter_values, **plot_options) # type: ignore
|
|
104
104
|
else:
|
|
105
|
-
ax.step(parameter_values, bin_values, **plot_options)
|
|
105
|
+
ax.step(parameter_values, bin_values, **plot_options) # type: ignore
|
|
106
106
|
|
|
107
107
|
set_semilog = ax.semilogy if cdf_on_x else ax.semilogx
|
|
108
108
|
set_lim = ax.set_xlim if cdf_on_x else ax.set_ylim
|
|
@@ -128,7 +128,7 @@ def integrated_histogram(
|
|
|
128
128
|
|
|
129
129
|
if median_line:
|
|
130
130
|
set_line(
|
|
131
|
-
np.median(float_data),
|
|
131
|
+
float(np.median(float_data)),
|
|
132
132
|
linestyle='--',
|
|
133
133
|
color=plot_options['color'],
|
|
134
134
|
alpha=0.5,
|
|
@@ -136,7 +136,7 @@ def integrated_histogram(
|
|
|
136
136
|
)
|
|
137
137
|
if mean_line:
|
|
138
138
|
set_line(
|
|
139
|
-
np.mean(float_data),
|
|
139
|
+
float(np.mean(float_data)),
|
|
140
140
|
linestyle='-.',
|
|
141
141
|
color=plot_options['color'],
|
|
142
142
|
alpha=0.5,
|
cirq/vis/state_histogram.py
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
"""Tool to visualize the results of a study."""
|
|
16
16
|
|
|
17
|
-
from typing import
|
|
17
|
+
from typing import cast, Optional, Sequence, SupportsFloat, Union
|
|
18
18
|
import collections
|
|
19
19
|
import numpy as np
|
|
20
20
|
import matplotlib.pyplot as plt
|
|
@@ -51,13 +51,13 @@ def get_state_histogram(result: 'result.Result') -> np.ndarray:
|
|
|
51
51
|
|
|
52
52
|
def plot_state_histogram(
|
|
53
53
|
data: Union['result.Result', collections.Counter, Sequence[SupportsFloat]],
|
|
54
|
-
ax: Optional[
|
|
54
|
+
ax: Optional[plt.Axes] = None,
|
|
55
55
|
*,
|
|
56
56
|
tick_label: Optional[Sequence[str]] = None,
|
|
57
57
|
xlabel: Optional[str] = 'qubit state',
|
|
58
58
|
ylabel: Optional[str] = 'result count',
|
|
59
59
|
title: Optional[str] = 'Result State Histogram',
|
|
60
|
-
) ->
|
|
60
|
+
) -> plt.Axes:
|
|
61
61
|
"""Plot the state histogram from either a single result with repetitions or
|
|
62
62
|
a histogram computed using `result.histogram()` or a flattened histogram
|
|
63
63
|
of measurement results computed using `get_state_histogram`.
|
|
@@ -87,6 +87,7 @@ def plot_state_histogram(
|
|
|
87
87
|
show_fig = not ax
|
|
88
88
|
if not ax:
|
|
89
89
|
fig, ax = plt.subplots(1, 1)
|
|
90
|
+
ax = cast(plt.Axes, ax)
|
|
90
91
|
if isinstance(data, result.Result):
|
|
91
92
|
values = get_state_histogram(data)
|
|
92
93
|
elif isinstance(data, collections.Counter):
|
|
@@ -96,9 +97,12 @@ def plot_state_histogram(
|
|
|
96
97
|
if tick_label is None:
|
|
97
98
|
tick_label = [str(i) for i in range(len(values))]
|
|
98
99
|
ax.bar(np.arange(len(values)), values, tick_label=tick_label)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
if xlabel:
|
|
101
|
+
ax.set_xlabel(xlabel)
|
|
102
|
+
if ylabel:
|
|
103
|
+
ax.set_ylabel(ylabel)
|
|
104
|
+
if title:
|
|
105
|
+
ax.set_title(title)
|
|
102
106
|
if show_fig:
|
|
103
107
|
fig.show()
|
|
104
108
|
return ax
|
cirq/vis/state_histogram_test.py
CHANGED
|
@@ -78,6 +78,8 @@ def test_plot_state_histogram_result():
|
|
|
78
78
|
for r1, r2 in zip(ax1.get_children(), ax2.get_children()):
|
|
79
79
|
if isinstance(r1, mpl.patches.Rectangle) and isinstance(r2, mpl.patches.Rectangle):
|
|
80
80
|
assert str(r1) == str(r2)
|
|
81
|
+
# Test default axis
|
|
82
|
+
state_histogram.plot_state_histogram(expected_values)
|
|
81
83
|
|
|
82
84
|
|
|
83
85
|
@pytest.mark.usefixtures('closefigures')
|
|
@@ -112,7 +112,7 @@ def test_observable_measured_result():
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
|
|
115
|
-
@pytest.fixture
|
|
115
|
+
@pytest.fixture
|
|
116
116
|
def example_bsa() -> 'cw.BitstringAccumulator':
|
|
117
117
|
"""Test fixture to create an (empty) example BitstringAccumulator"""
|
|
118
118
|
q0, q1 = cirq.LineQubit.range(2)
|
|
@@ -432,7 +432,7 @@ def _get_some_grouped_settings():
|
|
|
432
432
|
|
|
433
433
|
|
|
434
434
|
def test_measure_grouped_settings_calibration_validation():
|
|
435
|
-
|
|
435
|
+
mock_ro_calib = _MockBitstringAccumulator()
|
|
436
436
|
grouped_settings, qubits = _get_some_grouped_settings()
|
|
437
437
|
|
|
438
438
|
with pytest.raises(
|
|
@@ -443,7 +443,7 @@ def test_measure_grouped_settings_calibration_validation():
|
|
|
443
443
|
grouped_settings=grouped_settings,
|
|
444
444
|
sampler=cirq.Simulator(),
|
|
445
445
|
stopping_criteria=cw.RepetitionsStoppingCriteria(10_000),
|
|
446
|
-
readout_calibrations=
|
|
446
|
+
readout_calibrations=mock_ro_calib,
|
|
447
447
|
readout_symmetrization=False, # no-no!
|
|
448
448
|
)
|
|
449
449
|
|
cirq/work/zeros_sampler.py
CHANGED
|
@@ -24,7 +24,7 @@ if TYPE_CHECKING:
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
class ZerosSampler(work.Sampler, metaclass=abc.ABCMeta):
|
|
27
|
-
"""A
|
|
27
|
+
"""A mock sampler for testing. Immediately returns zeroes."""
|
|
28
28
|
|
|
29
29
|
def __init__(self, device: Optional[devices.Device] = None):
|
|
30
30
|
"""Construct a sampler that returns 0 for all measurements.
|
|
@@ -1,38 +1,32 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cirq-core
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
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
|
|
7
7
|
Author-email: cirq-dev@googlegroups.com
|
|
8
8
|
License: Apache 2
|
|
9
|
-
Platform: UNKNOWN
|
|
10
9
|
Requires-Python: >=3.9.0
|
|
11
10
|
License-File: LICENSE
|
|
12
|
-
Requires-Dist: duet
|
|
13
|
-
Requires-Dist: matplotlib
|
|
14
|
-
Requires-Dist: networkx
|
|
15
|
-
Requires-Dist: numpy
|
|
11
|
+
Requires-Dist: duet ~=0.2.8
|
|
12
|
+
Requires-Dist: matplotlib ~=3.0
|
|
13
|
+
Requires-Dist: networkx >=2.4
|
|
14
|
+
Requires-Dist: numpy ~=1.16
|
|
16
15
|
Requires-Dist: pandas
|
|
17
|
-
Requires-Dist: sortedcontainers
|
|
16
|
+
Requires-Dist: sortedcontainers ~=2.0
|
|
18
17
|
Requires-Dist: scipy
|
|
19
18
|
Requires-Dist: sympy
|
|
20
|
-
Requires-Dist: typing-extensions
|
|
19
|
+
Requires-Dist: typing-extensions >=4.2
|
|
21
20
|
Requires-Dist: tqdm
|
|
22
21
|
Provides-Extra: contrib
|
|
23
|
-
Requires-Dist: ply
|
|
24
|
-
Requires-Dist: pylatex
|
|
22
|
+
Requires-Dist: ply >=3.6 ; extra == 'contrib'
|
|
23
|
+
Requires-Dist: pylatex ~=1.3.0 ; extra == 'contrib'
|
|
25
24
|
Requires-Dist: quimb ; extra == 'contrib'
|
|
26
25
|
Requires-Dist: opt-einsum ; extra == 'contrib'
|
|
27
26
|
Requires-Dist: autoray ; extra == 'contrib'
|
|
28
|
-
Requires-Dist: numba
|
|
27
|
+
Requires-Dist: numba >=0.53.0 ; extra == 'contrib'
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
**For the latest stable release of Cirq-core see**
|
|
33
|
-
`here <https://pypi.org/project/cirq-core>`__.
|
|
34
|
-
|
|
35
|
-
.. image:: https://raw.githubusercontent.com/quantumlib/Cirq/master/docs/images/Cirq_logo_color.png
|
|
29
|
+
.. image:: https://raw.githubusercontent.com/quantumlib/Cirq/main/docs/images/Cirq_logo_color.png
|
|
36
30
|
:target: https://github.com/quantumlib/cirq
|
|
37
31
|
:alt: Cirq
|
|
38
32
|
:width: 500px
|
|
@@ -50,5 +44,3 @@ To install the stable version of only **cirq-core**, use `pip install cirq-core`
|
|
|
50
44
|
To install the pre-release version of only **cirq-core**, use `pip install cirq-core --pre`.
|
|
51
45
|
|
|
52
46
|
To get all the optional modules installed as well, you'll have to use `pip install cirq` or `pip install cirq --pre` for the pre-release version.
|
|
53
|
-
|
|
54
|
-
|