cirq-core 1.5.0.dev20250115162458__py3-none-any.whl → 1.5.0.dev20250115165326__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 +1 -1
- cirq/_version_test.py +1 -1
- cirq/transformers/measurement_transformers.py +14 -1
- cirq/transformers/measurement_transformers_test.py +35 -0
- {cirq_core-1.5.0.dev20250115162458.dist-info → cirq_core-1.5.0.dev20250115165326.dist-info}/METADATA +1 -1
- {cirq_core-1.5.0.dev20250115162458.dist-info → cirq_core-1.5.0.dev20250115165326.dist-info}/RECORD +9 -9
- {cirq_core-1.5.0.dev20250115162458.dist-info → cirq_core-1.5.0.dev20250115165326.dist-info}/LICENSE +0 -0
- {cirq_core-1.5.0.dev20250115162458.dist-info → cirq_core-1.5.0.dev20250115165326.dist-info}/WHEEL +0 -0
- {cirq_core-1.5.0.dev20250115162458.dist-info → cirq_core-1.5.0.dev20250115165326.dist-info}/top_level.txt +0 -0
cirq/_version.py
CHANGED
cirq/_version_test.py
CHANGED
|
@@ -292,7 +292,20 @@ def drop_terminal_measurements(
|
|
|
292
292
|
def flip_inversion(op: 'cirq.Operation', _) -> 'cirq.OP_TREE':
|
|
293
293
|
if isinstance(op.gate, ops.MeasurementGate):
|
|
294
294
|
return [
|
|
295
|
-
|
|
295
|
+
(
|
|
296
|
+
(ops.X if b else ops.I)
|
|
297
|
+
if q.dimension == 2
|
|
298
|
+
else (
|
|
299
|
+
ops.MatrixGate(
|
|
300
|
+
# Per SimulationState.measure(), swap 0,1 but leave other dims alone
|
|
301
|
+
np.eye(q.dimension)[[1, 0, *range(2, q.dimension)]],
|
|
302
|
+
qid_shape=(q.dimension,),
|
|
303
|
+
)
|
|
304
|
+
if b
|
|
305
|
+
else ops.IdentityGate(qid_shape=(q.dimension,))
|
|
306
|
+
)
|
|
307
|
+
).on(q)
|
|
308
|
+
for q, b in zip(op.qubits, op.gate.full_invert_mask())
|
|
296
309
|
]
|
|
297
310
|
return op
|
|
298
311
|
|
|
@@ -759,6 +759,41 @@ def test_drop_terminal():
|
|
|
759
759
|
)
|
|
760
760
|
|
|
761
761
|
|
|
762
|
+
def test_drop_terminal_qudit():
|
|
763
|
+
q0, q1 = cirq.LineQid.range(2, dimension=3)
|
|
764
|
+
circuit = cirq.Circuit(
|
|
765
|
+
cirq.CircuitOperation(cirq.FrozenCircuit(cirq.measure(q0, q1, key='m', invert_mask=[0, 1])))
|
|
766
|
+
)
|
|
767
|
+
dropped = cirq.drop_terminal_measurements(circuit)
|
|
768
|
+
expected_inversion_matrix = np.array([[0, 1, 0], [1, 0, 0], [0, 0, 1]])
|
|
769
|
+
cirq.testing.assert_same_circuits(
|
|
770
|
+
dropped,
|
|
771
|
+
cirq.Circuit(
|
|
772
|
+
cirq.CircuitOperation(
|
|
773
|
+
cirq.FrozenCircuit(
|
|
774
|
+
cirq.IdentityGate(qid_shape=(3,)).on(q0),
|
|
775
|
+
cirq.MatrixGate(expected_inversion_matrix, qid_shape=(3,)).on(q1),
|
|
776
|
+
)
|
|
777
|
+
)
|
|
778
|
+
),
|
|
779
|
+
)
|
|
780
|
+
# Verify behavior equivalent to simulator (invert_mask swaps 0,1 but leaves 2 alone)
|
|
781
|
+
dropped.append(cirq.measure(q0, q1, key='m'))
|
|
782
|
+
sim = cirq.Simulator()
|
|
783
|
+
c0 = sim.simulate(circuit, initial_state=[0, 0])
|
|
784
|
+
d0 = sim.simulate(dropped, initial_state=[0, 0])
|
|
785
|
+
assert np.all(c0.measurements['m'] == [0, 1])
|
|
786
|
+
assert np.all(d0.measurements['m'] == [0, 1])
|
|
787
|
+
c1 = sim.simulate(circuit, initial_state=[1, 1])
|
|
788
|
+
d1 = sim.simulate(dropped, initial_state=[1, 1])
|
|
789
|
+
assert np.all(c1.measurements['m'] == [1, 0])
|
|
790
|
+
assert np.all(d1.measurements['m'] == [1, 0])
|
|
791
|
+
c2 = sim.simulate(circuit, initial_state=[2, 2])
|
|
792
|
+
d2 = sim.simulate(dropped, initial_state=[2, 2])
|
|
793
|
+
assert np.all(c2.measurements['m'] == [2, 2])
|
|
794
|
+
assert np.all(d2.measurements['m'] == [2, 2])
|
|
795
|
+
|
|
796
|
+
|
|
762
797
|
def test_drop_terminal_nonterminal_error():
|
|
763
798
|
q0, q1 = cirq.LineQubit.range(2)
|
|
764
799
|
circuit = cirq.Circuit(
|
{cirq_core-1.5.0.dev20250115162458.dist-info → cirq_core-1.5.0.dev20250115165326.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cirq-core
|
|
3
|
-
Version: 1.5.0.
|
|
3
|
+
Version: 1.5.0.dev20250115165326
|
|
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
|
{cirq_core-1.5.0.dev20250115162458.dist-info → cirq_core-1.5.0.dev20250115165326.dist-info}/RECORD
RENAMED
|
@@ -4,8 +4,8 @@ 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=
|
|
8
|
-
cirq/_version_test.py,sha256=
|
|
7
|
+
cirq/_version.py,sha256=4HKhyytzlgT5VUdif6rpA_yMAVt-W_kit7R-b8bzZW0,1206
|
|
8
|
+
cirq/_version_test.py,sha256=MThOmEhx5kC-xVacYVPapna26JqSTe_ATeHYx_BrvgM,147
|
|
9
9
|
cirq/conftest.py,sha256=X7yLFL8GLhg2CjPw0hp5e_dGASfvHx1-QT03aUbhKJw,1168
|
|
10
10
|
cirq/json_resolver_cache.py,sha256=cpbvJMNIh0U-l1mEVb-TqhJUEXfm2vpuR3v432ORSmg,13702
|
|
11
11
|
cirq/py.typed,sha256=VFSlmh_lNwnaXzwY-ZuW-C2Ws5PkuDoVgBdNCs0jXJE,63
|
|
@@ -1056,8 +1056,8 @@ cirq/transformers/expand_composite.py,sha256=nASRoP4qfjsnX_t2a2hBw8BE7B_JD-0XLGI
|
|
|
1056
1056
|
cirq/transformers/expand_composite_test.py,sha256=4Gn6LVqr0DeuUumde80O4esOLGIoo86_S_Mk-HwnMfk,8640
|
|
1057
1057
|
cirq/transformers/insertion_sort.py,sha256=cAwseOcAdBFoPlP8F45B_XP8ySGmkPHn0EftTVVsF9Q,2612
|
|
1058
1058
|
cirq/transformers/insertion_sort_test.py,sha256=q81tMHSmlxTRqznkfgIGxanF-1fX8GclopAHTaF6yHs,1187
|
|
1059
|
-
cirq/transformers/measurement_transformers.py,sha256=
|
|
1060
|
-
cirq/transformers/measurement_transformers_test.py,sha256=
|
|
1059
|
+
cirq/transformers/measurement_transformers.py,sha256=ewHTeY8QuEYCXact4XVCKD-VCCAGg3OaQiVDonSH8dE,19581
|
|
1060
|
+
cirq/transformers/measurement_transformers_test.py,sha256=VXXqJIfXJcduJXXXz0_yq7onAlAe3FDd7l3EHmp9YyM,28983
|
|
1061
1061
|
cirq/transformers/merge_k_qubit_gates.py,sha256=dUsswQOIHfbb6Lu37fecgrpT6_45zmDE7eqCUbW1KOI,4390
|
|
1062
1062
|
cirq/transformers/merge_k_qubit_gates_test.py,sha256=k_ROZvUebHgPy5vsNnWNMBYU4kfIkrunPsw39ZngMwo,13920
|
|
1063
1063
|
cirq/transformers/merge_single_qubit_gates.py,sha256=NRREV4Z6Ptc3mZnOUgzQePdj4H0aix17WOUwZUB7iQ8,5826
|
|
@@ -1203,8 +1203,8 @@ cirq/work/sampler.py,sha256=bE5tmVkcR6cZZMLETxDfHehdsYUMbx2RvBeIBetehI4,19187
|
|
|
1203
1203
|
cirq/work/sampler_test.py,sha256=hL2UWx3dz2ukZVNxWftiKVvJcQoLplLZdQm-k1QcA40,13282
|
|
1204
1204
|
cirq/work/zeros_sampler.py,sha256=x1C7cup66a43n-3tm8QjhiqJa07qcJW10FxNp9jJ59Q,2356
|
|
1205
1205
|
cirq/work/zeros_sampler_test.py,sha256=JIkpBBFPJe5Ba4142vzogyWyboG1Q1ZAm0UVGgOoZn8,3279
|
|
1206
|
-
cirq_core-1.5.0.
|
|
1207
|
-
cirq_core-1.5.0.
|
|
1208
|
-
cirq_core-1.5.0.
|
|
1209
|
-
cirq_core-1.5.0.
|
|
1210
|
-
cirq_core-1.5.0.
|
|
1206
|
+
cirq_core-1.5.0.dev20250115165326.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
|
|
1207
|
+
cirq_core-1.5.0.dev20250115165326.dist-info/METADATA,sha256=T30LV9EsQx6VJtuGT1nUh6s07YMRG6zLahSfPOci4TI,2105
|
|
1208
|
+
cirq_core-1.5.0.dev20250115165326.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
1209
|
+
cirq_core-1.5.0.dev20250115165326.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
|
|
1210
|
+
cirq_core-1.5.0.dev20250115165326.dist-info/RECORD,,
|
{cirq_core-1.5.0.dev20250115162458.dist-info → cirq_core-1.5.0.dev20250115165326.dist-info}/LICENSE
RENAMED
|
File without changes
|
{cirq_core-1.5.0.dev20250115162458.dist-info → cirq_core-1.5.0.dev20250115165326.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|