cirq-core 1.5.0.dev20250117174100__py3-none-any.whl → 1.5.0.dev20250118135200__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/ops/common_channels.py +8 -34
- cirq/ops/common_channels_test.py +10 -0
- {cirq_core-1.5.0.dev20250117174100.dist-info → cirq_core-1.5.0.dev20250118135200.dist-info}/METADATA +1 -1
- {cirq_core-1.5.0.dev20250117174100.dist-info → cirq_core-1.5.0.dev20250118135200.dist-info}/RECORD +9 -9
- {cirq_core-1.5.0.dev20250117174100.dist-info → cirq_core-1.5.0.dev20250118135200.dist-info}/LICENSE +0 -0
- {cirq_core-1.5.0.dev20250117174100.dist-info → cirq_core-1.5.0.dev20250118135200.dist-info}/WHEEL +0 -0
- {cirq_core-1.5.0.dev20250117174100.dist-info → cirq_core-1.5.0.dev20250118135200.dist-info}/top_level.txt +0 -0
cirq/_version.py
CHANGED
cirq/_version_test.py
CHANGED
cirq/ops/common_channels.py
CHANGED
|
@@ -27,7 +27,7 @@ if TYPE_CHECKING:
|
|
|
27
27
|
import cirq
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
@value.value_equality
|
|
30
|
+
@value.value_equality(approximate=True)
|
|
31
31
|
class AsymmetricDepolarizingChannel(raw_types.Gate):
|
|
32
32
|
r"""A channel that depolarizes asymmetrically along different directions.
|
|
33
33
|
|
|
@@ -196,11 +196,6 @@ class AsymmetricDepolarizingChannel(raw_types.Gate):
|
|
|
196
196
|
def _json_dict_(self) -> Dict[str, Any]:
|
|
197
197
|
return protocols.obj_to_dict_helper(self, ['error_probabilities'])
|
|
198
198
|
|
|
199
|
-
def _approx_eq_(self, other: Any, atol: float) -> bool:
|
|
200
|
-
self_keys, self_values = zip(*sorted(self.error_probabilities.items()))
|
|
201
|
-
other_keys, other_values = zip(*sorted(other.error_probabilities.items()))
|
|
202
|
-
return self_keys == other_keys and protocols.approx_eq(self_values, other_values, atol=atol)
|
|
203
|
-
|
|
204
199
|
|
|
205
200
|
def asymmetric_depolarize(
|
|
206
201
|
p_x: Optional[float] = None,
|
|
@@ -246,7 +241,7 @@ def asymmetric_depolarize(
|
|
|
246
241
|
return AsymmetricDepolarizingChannel(p_x, p_y, p_z, error_probabilities, tol)
|
|
247
242
|
|
|
248
243
|
|
|
249
|
-
@value.value_equality
|
|
244
|
+
@value.value_equality(approximate=True)
|
|
250
245
|
class DepolarizingChannel(raw_types.Gate):
|
|
251
246
|
r"""A channel that depolarizes one or several qubits.
|
|
252
247
|
|
|
@@ -306,7 +301,7 @@ class DepolarizingChannel(raw_types.Gate):
|
|
|
306
301
|
return True
|
|
307
302
|
|
|
308
303
|
def _value_equality_values_(self):
|
|
309
|
-
return self._p
|
|
304
|
+
return self._p, self._n_qubits
|
|
310
305
|
|
|
311
306
|
def __repr__(self) -> str:
|
|
312
307
|
if self._n_qubits == 1:
|
|
@@ -347,9 +342,6 @@ class DepolarizingChannel(raw_types.Gate):
|
|
|
347
342
|
return protocols.obj_to_dict_helper(self, ['p'])
|
|
348
343
|
return protocols.obj_to_dict_helper(self, ['p', 'n_qubits'])
|
|
349
344
|
|
|
350
|
-
def _approx_eq_(self, other: Any, atol: float) -> bool:
|
|
351
|
-
return np.isclose(self.p, other.p, atol=atol).item() and self.n_qubits == other.n_qubits
|
|
352
|
-
|
|
353
345
|
|
|
354
346
|
def depolarize(p: float, n_qubits: int = 1) -> DepolarizingChannel:
|
|
355
347
|
r"""Returns a DepolarizingChannel with given probability of error.
|
|
@@ -381,7 +373,7 @@ def depolarize(p: float, n_qubits: int = 1) -> DepolarizingChannel:
|
|
|
381
373
|
return DepolarizingChannel(p, n_qubits)
|
|
382
374
|
|
|
383
375
|
|
|
384
|
-
@value.value_equality
|
|
376
|
+
@value.value_equality(approximate=True)
|
|
385
377
|
class GeneralizedAmplitudeDampingChannel(raw_types.Gate):
|
|
386
378
|
r"""Dampen qubit amplitudes through non ideal dissipation.
|
|
387
379
|
|
|
@@ -489,12 +481,6 @@ class GeneralizedAmplitudeDampingChannel(raw_types.Gate):
|
|
|
489
481
|
def _json_dict_(self) -> Dict[str, Any]:
|
|
490
482
|
return protocols.obj_to_dict_helper(self, ['p', 'gamma'])
|
|
491
483
|
|
|
492
|
-
def _approx_eq_(self, other: Any, atol: float) -> bool:
|
|
493
|
-
return (
|
|
494
|
-
np.isclose(self.gamma, other.gamma, atol=atol).item()
|
|
495
|
-
and np.isclose(self.p, other.p, atol=atol).item()
|
|
496
|
-
)
|
|
497
|
-
|
|
498
484
|
|
|
499
485
|
def generalized_amplitude_damp(p: float, gamma: float) -> GeneralizedAmplitudeDampingChannel:
|
|
500
486
|
r"""Returns a GeneralizedAmplitudeDampingChannel with probabilities gamma and p.
|
|
@@ -542,7 +528,7 @@ def generalized_amplitude_damp(p: float, gamma: float) -> GeneralizedAmplitudeDa
|
|
|
542
528
|
return GeneralizedAmplitudeDampingChannel(p, gamma)
|
|
543
529
|
|
|
544
530
|
|
|
545
|
-
@value.value_equality
|
|
531
|
+
@value.value_equality(approximate=True)
|
|
546
532
|
class AmplitudeDampingChannel(raw_types.Gate):
|
|
547
533
|
r"""Dampen qubit amplitudes through dissipation.
|
|
548
534
|
|
|
@@ -619,9 +605,6 @@ class AmplitudeDampingChannel(raw_types.Gate):
|
|
|
619
605
|
def _json_dict_(self) -> Dict[str, Any]:
|
|
620
606
|
return protocols.obj_to_dict_helper(self, ['gamma'])
|
|
621
607
|
|
|
622
|
-
def _approx_eq_(self, other: Any, atol: float) -> bool:
|
|
623
|
-
return np.isclose(self.gamma, other.gamma, atol=atol).item()
|
|
624
|
-
|
|
625
608
|
|
|
626
609
|
def amplitude_damp(gamma: float) -> AmplitudeDampingChannel:
|
|
627
610
|
r"""Returns an AmplitudeDampingChannel with the given probability gamma.
|
|
@@ -787,7 +770,7 @@ def reset_each(*qubits: 'cirq.Qid') -> List[raw_types.Operation]:
|
|
|
787
770
|
return [ResetChannel(q.dimension).on(q) for q in qubits]
|
|
788
771
|
|
|
789
772
|
|
|
790
|
-
@value.value_equality
|
|
773
|
+
@value.value_equality(approximate=True)
|
|
791
774
|
class PhaseDampingChannel(raw_types.Gate):
|
|
792
775
|
r"""Dampen qubit phase.
|
|
793
776
|
|
|
@@ -881,9 +864,6 @@ class PhaseDampingChannel(raw_types.Gate):
|
|
|
881
864
|
def _json_dict_(self) -> Dict[str, Any]:
|
|
882
865
|
return protocols.obj_to_dict_helper(self, ['gamma'])
|
|
883
866
|
|
|
884
|
-
def _approx_eq_(self, other: Any, atol: float) -> bool:
|
|
885
|
-
return np.isclose(self._gamma, other._gamma, atol=atol).item()
|
|
886
|
-
|
|
887
867
|
|
|
888
868
|
def phase_damp(gamma: float) -> PhaseDampingChannel:
|
|
889
869
|
r"""Creates a PhaseDampingChannel with damping constant gamma.
|
|
@@ -919,7 +899,7 @@ def phase_damp(gamma: float) -> PhaseDampingChannel:
|
|
|
919
899
|
return PhaseDampingChannel(gamma)
|
|
920
900
|
|
|
921
901
|
|
|
922
|
-
@value.value_equality
|
|
902
|
+
@value.value_equality(approximate=True)
|
|
923
903
|
class PhaseFlipChannel(raw_types.Gate):
|
|
924
904
|
r"""Probabilistically flip the sign of the phase of a qubit.
|
|
925
905
|
|
|
@@ -991,9 +971,6 @@ class PhaseFlipChannel(raw_types.Gate):
|
|
|
991
971
|
def _json_dict_(self) -> Dict[str, Any]:
|
|
992
972
|
return protocols.obj_to_dict_helper(self, ['p'])
|
|
993
973
|
|
|
994
|
-
def _approx_eq_(self, other: Any, atol: float) -> bool:
|
|
995
|
-
return np.isclose(self.p, other.p, atol=atol).item()
|
|
996
|
-
|
|
997
974
|
|
|
998
975
|
def _phase_flip_Z() -> common_gates.ZPowGate:
|
|
999
976
|
"""Returns a cirq.Z which corresponds to a guaranteed phase flip."""
|
|
@@ -1073,7 +1050,7 @@ def phase_flip(p: Optional[float] = None) -> Union[common_gates.ZPowGate, PhaseF
|
|
|
1073
1050
|
return _phase_flip(p)
|
|
1074
1051
|
|
|
1075
1052
|
|
|
1076
|
-
@value.value_equality
|
|
1053
|
+
@value.value_equality(approximate=True)
|
|
1077
1054
|
class BitFlipChannel(raw_types.Gate):
|
|
1078
1055
|
r"""Probabilistically flip a qubit from 1 to 0 state or vice versa.
|
|
1079
1056
|
|
|
@@ -1148,9 +1125,6 @@ class BitFlipChannel(raw_types.Gate):
|
|
|
1148
1125
|
def _json_dict_(self) -> Dict[str, Any]:
|
|
1149
1126
|
return protocols.obj_to_dict_helper(self, ['p'])
|
|
1150
1127
|
|
|
1151
|
-
def _approx_eq_(self, other: Any, atol: float) -> bool:
|
|
1152
|
-
return np.isclose(self._p, other._p, atol=atol).item()
|
|
1153
|
-
|
|
1154
1128
|
|
|
1155
1129
|
def _bit_flip(p: float) -> BitFlipChannel:
|
|
1156
1130
|
r"""Construct a BitFlipChannel that flips a qubit state with probability of a flip given by p.
|
cirq/ops/common_channels_test.py
CHANGED
|
@@ -92,6 +92,7 @@ def test_asymmetric_depolarizing_channel_eq():
|
|
|
92
92
|
c = cirq.asymmetric_depolarize(0.0, 0.0, 0.0)
|
|
93
93
|
|
|
94
94
|
assert cirq.approx_eq(a, b, atol=1e-2)
|
|
95
|
+
assert not cirq.approx_eq(a, cirq.X)
|
|
95
96
|
|
|
96
97
|
et = cirq.testing.EqualsTester()
|
|
97
98
|
et.make_equality_group(lambda: c)
|
|
@@ -276,6 +277,7 @@ def test_depolarizing_channel_eq():
|
|
|
276
277
|
c = cirq.depolarize(0.0)
|
|
277
278
|
|
|
278
279
|
assert cirq.approx_eq(a, b, atol=1e-2)
|
|
280
|
+
assert not cirq.approx_eq(a, cirq.X)
|
|
279
281
|
|
|
280
282
|
et = cirq.testing.EqualsTester()
|
|
281
283
|
|
|
@@ -283,6 +285,7 @@ def test_depolarizing_channel_eq():
|
|
|
283
285
|
et.add_equality_group(cirq.depolarize(0.1))
|
|
284
286
|
et.add_equality_group(cirq.depolarize(0.9))
|
|
285
287
|
et.add_equality_group(cirq.depolarize(1.0))
|
|
288
|
+
et.add_equality_group(cirq.depolarize(1.0, n_qubits=2))
|
|
286
289
|
|
|
287
290
|
|
|
288
291
|
def test_depolarizing_channel_invalid_probability():
|
|
@@ -349,6 +352,7 @@ def test_generalized_amplitude_damping_channel_eq():
|
|
|
349
352
|
b = cirq.generalized_amplitude_damp(0.01, 0.0099999)
|
|
350
353
|
|
|
351
354
|
assert cirq.approx_eq(a, b, atol=1e-2)
|
|
355
|
+
assert not cirq.approx_eq(a, cirq.X)
|
|
352
356
|
|
|
353
357
|
et = cirq.testing.EqualsTester()
|
|
354
358
|
c = cirq.generalized_amplitude_damp(0.0, 0.0)
|
|
@@ -411,6 +415,7 @@ def test_amplitude_damping_channel_eq():
|
|
|
411
415
|
c = cirq.amplitude_damp(0.0)
|
|
412
416
|
|
|
413
417
|
assert cirq.approx_eq(a, b, atol=1e-2)
|
|
418
|
+
assert not cirq.approx_eq(a, cirq.X)
|
|
414
419
|
|
|
415
420
|
et = cirq.testing.EqualsTester()
|
|
416
421
|
et.make_equality_group(lambda: c)
|
|
@@ -562,6 +567,7 @@ def test_phase_damping_channel_eq():
|
|
|
562
567
|
c = cirq.phase_damp(0.0)
|
|
563
568
|
|
|
564
569
|
assert cirq.approx_eq(a, b, atol=1e-2)
|
|
570
|
+
assert not cirq.approx_eq(a, cirq.X)
|
|
565
571
|
|
|
566
572
|
et = cirq.testing.EqualsTester()
|
|
567
573
|
et.make_equality_group(lambda: c)
|
|
@@ -636,6 +642,7 @@ def test_phase_flip_channel_eq():
|
|
|
636
642
|
c = cirq.phase_flip(0.0)
|
|
637
643
|
|
|
638
644
|
assert cirq.approx_eq(a, b, atol=1e-2)
|
|
645
|
+
assert not cirq.approx_eq(a, cirq.X)
|
|
639
646
|
|
|
640
647
|
et = cirq.testing.EqualsTester()
|
|
641
648
|
et.make_equality_group(lambda: c)
|
|
@@ -701,6 +708,7 @@ def test_bit_flip_channel_eq():
|
|
|
701
708
|
c = cirq.bit_flip(0.0)
|
|
702
709
|
|
|
703
710
|
assert cirq.approx_eq(a, b, atol=1e-2)
|
|
711
|
+
assert not cirq.approx_eq(a, cirq.X)
|
|
704
712
|
|
|
705
713
|
et = cirq.testing.EqualsTester()
|
|
706
714
|
et.make_equality_group(lambda: c)
|
|
@@ -834,6 +842,8 @@ def test_multi_asymmetric_depolarizing_eq():
|
|
|
834
842
|
|
|
835
843
|
assert cirq.approx_eq(a, b, atol=1e-3)
|
|
836
844
|
|
|
845
|
+
assert not cirq.approx_eq(a, cirq.X)
|
|
846
|
+
|
|
837
847
|
|
|
838
848
|
def test_multi_asymmetric_depolarizing_channel_str():
|
|
839
849
|
assert str(cirq.asymmetric_depolarize(error_probabilities={'II': 0.8, 'XX': 0.2})) == (
|
{cirq_core-1.5.0.dev20250117174100.dist-info → cirq_core-1.5.0.dev20250118135200.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.dev20250118135200
|
|
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.dev20250117174100.dist-info → cirq_core-1.5.0.dev20250118135200.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=xmqt47lnMTmm8rS7b1oeqZSno_8t-pGY6N7lNC_O4BI,1206
|
|
8
|
+
cirq/_version_test.py,sha256=EufjKhDf5JWmc5U1tMdfnJrg6o6Py51fVvDT5Ag3yBU,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
|
|
@@ -272,8 +272,8 @@ cirq/ops/classically_controlled_operation.py,sha256=M4NAcChYcz-a88oyIwOnV4uP06S1
|
|
|
272
272
|
cirq/ops/classically_controlled_operation_test.py,sha256=nIYyXfNH4E2IibZSLk6QDVHpfJQbuI_iWwirCH8rhi8,50209
|
|
273
273
|
cirq/ops/clifford_gate.py,sha256=MOmmW5ZhxzuPvBB7oJnIhKSpZWlyYwplew29h-UtmU8,39762
|
|
274
274
|
cirq/ops/clifford_gate_test.py,sha256=zEdXXDA-M7wkHO6GTlltcWz6qyEiF0UaiWP8NwRTUmY,39270
|
|
275
|
-
cirq/ops/common_channels.py,sha256=
|
|
276
|
-
cirq/ops/common_channels_test.py,sha256=
|
|
275
|
+
cirq/ops/common_channels.py,sha256=go4yhaRw0XNAr3TUBJ59SOhn2SKxf6bHmmrOHPbBYCY,37259
|
|
276
|
+
cirq/ops/common_channels_test.py,sha256=nQsSSxu7vtedb3ZUuw4hNKIX7MYI4x8lxvLyWMZNt10,30079
|
|
277
277
|
cirq/ops/common_gate_families.py,sha256=e5M8wlDYtdrpWBrhdns6iizIvSqzfxDyIsBdxt8hVMc,8611
|
|
278
278
|
cirq/ops/common_gate_families_test.py,sha256=Oo3C7BPO3gt3ePuqwsI_lx_lY38et8Ps4AuVydX2Aww,5275
|
|
279
279
|
cirq/ops/common_gates.py,sha256=9QAhME6hhj5UiW0xWpZ58ltII-h8t8DY1GoyMgeyMxo,58120
|
|
@@ -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.dev20250118135200.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
|
|
1207
|
+
cirq_core-1.5.0.dev20250118135200.dist-info/METADATA,sha256=48c3voaYdGjIxkmTTXLjlZuvfz8ZmbSgK33aae54egA,2105
|
|
1208
|
+
cirq_core-1.5.0.dev20250118135200.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
1209
|
+
cirq_core-1.5.0.dev20250118135200.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
|
|
1210
|
+
cirq_core-1.5.0.dev20250118135200.dist-info/RECORD,,
|
{cirq_core-1.5.0.dev20250117174100.dist-info → cirq_core-1.5.0.dev20250118135200.dist-info}/LICENSE
RENAMED
|
File without changes
|
{cirq_core-1.5.0.dev20250117174100.dist-info → cirq_core-1.5.0.dev20250118135200.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|