cirq-core 1.7.0.dev20251008130954__py3-none-any.whl → 1.7.0.dev20251008140155__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
@@ -28,4 +28,4 @@ if sys.version_info < (3, 11, 0): # pragma: no cover
28
28
  'of Cirq (e.g. "python -m pip install cirq==1.5.0")'
29
29
  )
30
30
 
31
- __version__ = "1.7.0.dev20251008130954"
31
+ __version__ = "1.7.0.dev20251008140155"
cirq/_version_test.py CHANGED
@@ -3,4 +3,4 @@ import cirq
3
3
 
4
4
 
5
5
  def test_version() -> None:
6
- assert cirq.__version__ == "1.7.0.dev20251008130954"
6
+ assert cirq.__version__ == "1.7.0.dev20251008140155"
cirq/ops/gateset.py CHANGED
@@ -340,6 +340,7 @@ class Gateset:
340
340
  self._unroll_circuit_op = unroll_circuit_op
341
341
  self._instance_gate_families: dict[raw_types.Gate, GateFamily] = {}
342
342
  self._type_gate_families: dict[type[raw_types.Gate], GateFamily] = {}
343
+ self._gate_families_with_tags: list[GateFamily] = []
343
344
  self._gates_repr_str = ", ".join([_gate_str(g, repr) for g in gates])
344
345
  unique_gate_list: list[GateFamily] = list(
345
346
  dict.fromkeys(g if isinstance(g, GateFamily) else GateFamily(gate=g) for g in gates)
@@ -351,6 +352,12 @@ class Gateset:
351
352
  self._instance_gate_families[g.gate] = g
352
353
  else:
353
354
  self._type_gate_families[g.gate] = g
355
+ else:
356
+ if isinstance(g.gate, raw_types.Gate):
357
+ self._gate_families_with_tags.append(g)
358
+ else:
359
+ # Instance checks are faster, so test them first.
360
+ self._gate_families_with_tags.insert(0, g)
354
361
  self._unique_gate_list = unique_gate_list
355
362
  self._gates = frozenset(unique_gate_list)
356
363
 
@@ -422,6 +429,7 @@ class Gateset:
422
429
  g = item if isinstance(item, raw_types.Gate) else item.gate
423
430
  assert g is not None, f'`item`: {item} must be a gate or have a valid `item.gate`'
424
431
 
432
+ # Check "type" based GateFamily since isinstance is fast
425
433
  for gate_mro_type in type(g).mro():
426
434
  if gate_mro_type in self._type_gate_families:
427
435
  assert item in self._type_gate_families[gate_mro_type], (
@@ -430,6 +438,7 @@ class Gateset:
430
438
  )
431
439
  return True
432
440
 
441
+ # Check exact instance equality next
433
442
  if g in self._instance_gate_families:
434
443
  assert item in self._instance_gate_families[g], (
435
444
  f"{item} instance matches {self._instance_gate_families[g]} but "
@@ -437,7 +446,17 @@ class Gateset:
437
446
  )
438
447
  return True
439
448
 
440
- return any(item in gate_family for gate_family in self._gates)
449
+ # Check other GateFamilies next
450
+ if any(item in gate_family for gate_family in self._gate_families_with_tags):
451
+ return True
452
+
453
+ # Lastly, do a final exhaustive check to make sure this is not equivalent
454
+ # to another type of gate. This will catch things like:
455
+ # cirq.XPowGate(exponent=0) in cirq.GateFamily(cirq.I)
456
+ return any(
457
+ item in gate_family
458
+ for gate_family in self._gates.difference(self._gate_families_with_tags)
459
+ )
441
460
 
442
461
  def validate(self, circuit_or_optree: cirq.AbstractCircuit | op_tree.OP_TREE) -> bool:
443
462
  """Validates gates forming `circuit_or_optree` should be contained in Gateset.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cirq-core
3
- Version: 1.7.0.dev20251008130954
3
+ Version: 1.7.0.dev20251008140155
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
@@ -4,8 +4,8 @@ cirq/_compat_test.py,sha256=emXpdD5ZvwLRlFAoQB8YatmZyU3b4e9jg6FppMTUhkU,33900
4
4
  cirq/_doc.py,sha256=28ZskY9ZtZ_4GS1oXPUgklKnJqmAE-rkUfzcsJ0--nA,2941
5
5
  cirq/_import.py,sha256=ixBu4EyGl46Ram2cP3p5eZVEFDW5L2DS-VyTjz4N9iw,8429
6
6
  cirq/_import_test.py,sha256=oF4izzOVZLc7NZ0aZHFcGv-r01eiFFt_JORx_x7_D4s,1089
7
- cirq/_version.py,sha256=zEApXE56A51QSELSvueLsKVwo9_DRJzUrIVYxkWC748,1206
8
- cirq/_version_test.py,sha256=vMlEWOtKNIclryX-XWBBmBhJqRBwbAxiIH8xcVDZmIk,155
7
+ cirq/_version.py,sha256=RmDz4vWV1FsTvyOIe8hwxqC7RyWmefeibdd5FTDtB6s,1206
8
+ cirq/_version_test.py,sha256=2qkxf-3n20QUBwT38sLGNVyDgrepqP2U6rhUfc2lIyM,155
9
9
  cirq/conftest.py,sha256=wSDKNdIQRDfLnXvOCWD3erheOw8JHRhdfQ53EyTUIXg,1239
10
10
  cirq/json_resolver_cache.py,sha256=A5DIgFAY1hUNt9vai_C3-gGBv24116CJMzQxMcXOax4,13726
11
11
  cirq/py.typed,sha256=VFSlmh_lNwnaXzwY-ZuW-C2Ws5PkuDoVgBdNCs0jXJE,63
@@ -322,7 +322,7 @@ cirq/ops/gate_features.py,sha256=OfjsIGftnGpNUDAYwSP4obG0FsMrHYfp49ZOjbvbmNE,108
322
322
  cirq/ops/gate_features_test.py,sha256=JYPunTBr48CQoIOB1wk2QEdPwtnmE-FxUoF6a4ZeRB8,2407
323
323
  cirq/ops/gate_operation.py,sha256=tyQOHZ_A_kGy6Yzn1fDTkHBNyzyvPmxbnueG6e5yOGM,13632
324
324
  cirq/ops/gate_operation_test.py,sha256=4QwWxCjGXNM__6QGw1kYSbBMh_4783jBZVBJD1ERGPk,18020
325
- cirq/ops/gateset.py,sha256=h_lCF6-SeUOprqulklRwBZg77kr_zNG_gvNuvPQc0pg,21786
325
+ cirq/ops/gateset.py,sha256=oJVaCZXk0bZGMitLrvWF9aa2GNPuvthvBS8sqsogoA0,22681
326
326
  cirq/ops/gateset_test.py,sha256=oeJ0zLgknWxgW39_bc_8Ii_5_g5VNxiJWicZkkS-TaE,17651
327
327
  cirq/ops/global_phase_op.py,sha256=GcERs4X5h5_at6tvJc8-AcM0cVsLCRPlpPkAWMINm54,5711
328
328
  cirq/ops/global_phase_op_test.py,sha256=9BBnPZLLmBzHsMoRPMFTAShx87TJnhTLvvgLpHJF4wc,10721
@@ -1244,8 +1244,8 @@ cirq/work/sampler.py,sha256=rxbMWvrhu3gfNSBjZKozw28lLKVvBAS_1EGyPdYe8Xg,19041
1244
1244
  cirq/work/sampler_test.py,sha256=SsMrRvLDYELyOAWLKISjkdEfrBwLYWRsT6D8WrsLM3Q,13533
1245
1245
  cirq/work/zeros_sampler.py,sha256=Fs2JWwq0n9zv7_G5Rm-9vPeHUag7uctcMOHg0JTkZpc,2371
1246
1246
  cirq/work/zeros_sampler_test.py,sha256=lQLgQDGBLtfImryys2HzQ2jOSGxHgc7-koVBUhv8qYk,3345
1247
- cirq_core-1.7.0.dev20251008130954.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1248
- cirq_core-1.7.0.dev20251008130954.dist-info/METADATA,sha256=9DVwXjrTvtg9eGR3ajz75_By0ZsbiBkxdIIM2pD-nD0,4757
1249
- cirq_core-1.7.0.dev20251008130954.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
1250
- cirq_core-1.7.0.dev20251008130954.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1251
- cirq_core-1.7.0.dev20251008130954.dist-info/RECORD,,
1247
+ cirq_core-1.7.0.dev20251008140155.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1248
+ cirq_core-1.7.0.dev20251008140155.dist-info/METADATA,sha256=oVA7D54pyqS8VAtY1QX6FOctZzQfinvF0GP3gIdiYIo,4757
1249
+ cirq_core-1.7.0.dev20251008140155.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
1250
+ cirq_core-1.7.0.dev20251008140155.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1251
+ cirq_core-1.7.0.dev20251008140155.dist-info/RECORD,,