cirq-core 1.4.0.dev20240509230054__py3-none-any.whl → 1.4.0.dev20240510015550__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.dev20240509230054"
1
+ __version__ = "1.4.0.dev20240510015550"
@@ -12,7 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- from typing import Any, Dict, Iterable, Sequence, Tuple, TYPE_CHECKING
15
+ from typing import Any, Dict, Sequence, Tuple, TYPE_CHECKING
16
16
 
17
17
  from cirq import protocols, value
18
18
  from cirq.ops import raw_types, swap_gates
@@ -74,23 +74,21 @@ class QubitPermutationGate(raw_types.Gate):
74
74
  return True
75
75
 
76
76
  def _decompose_(self, qubits: Sequence['cirq.Qid']) -> 'cirq.OP_TREE':
77
- n = len(qubits)
78
- qubit_ids = [*range(n)]
79
- is_sorted = False
80
-
81
- def _swap_if_out_of_order(idx: int) -> Iterable['cirq.Operation']:
82
- nonlocal is_sorted
83
- if self._permutation[qubit_ids[idx]] > self._permutation[qubit_ids[idx + 1]]:
84
- yield swap_gates.SWAP(qubits[idx], qubits[idx + 1])
85
- qubit_ids[idx + 1], qubit_ids[idx] = qubit_ids[idx], qubit_ids[idx + 1]
86
- is_sorted = False
87
-
88
- while not is_sorted:
89
- is_sorted = True
90
- for i in range(0, n - 1, 2):
91
- yield from _swap_if_out_of_order(i)
92
- for i in range(1, n - 1, 2):
93
- yield from _swap_if_out_of_order(i)
77
+ permutation = [p for p in self.permutation]
78
+
79
+ for i in range(len(permutation)):
80
+
81
+ if permutation[i] == -1:
82
+ continue
83
+ cycle = [i]
84
+ while permutation[cycle[-1]] != i:
85
+ cycle.append(permutation[cycle[-1]])
86
+
87
+ for j in cycle:
88
+ permutation[j] = -1
89
+
90
+ for idx in cycle[1:]:
91
+ yield swap_gates.SWAP(qubits[cycle[0]], qubits[idx])
94
92
 
95
93
  def _apply_unitary_(self, args: 'cirq.ApplyUnitaryArgs'):
96
94
  # Compute the permutation index list.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cirq-core
3
- Version: 1.4.0.dev20240509230054
3
+ Version: 1.4.0.dev20240510015550
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,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=s85Ny8GfmNBoQufs5PJadNHnMeMNcpzm09f_5ojFNnA,40
7
+ cirq/_version.py,sha256=VRM85uKV-Kp7rvn1dzixp7-Iy4Sbm__BMgM173_bsMc,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=9g_JQMmfBzTuV-3s2flUbXIgcLjs4K7LjAFFgngdG1U,13204
@@ -339,7 +339,7 @@ cirq/ops/pauli_string_raw_types_test.py,sha256=SZPluslZPGffPq93F5apESBygWZ2cj7BE
339
339
  cirq/ops/pauli_string_test.py,sha256=3sE7cAe6szKJ1WW3iI8S3oCYMJkSX4SCwPQWopcMR1Y,73772
340
340
  cirq/ops/pauli_sum_exponential.py,sha256=n3fhKWJVMudzGuOcdPHskVNx3fHE2MAblVdkzbDtcz4,4909
341
341
  cirq/ops/pauli_sum_exponential_test.py,sha256=wVnJ3FSpEimHT8ERVkmljALrgSuuDYo6GRg91uJ7ztk,5370
342
- cirq/ops/permutation_gate.py,sha256=i1BfUsXF2L4w4BlCAw9X2PnQQRE5gG37--fXF3cxihI,4449
342
+ cirq/ops/permutation_gate.py,sha256=5xTXmnjFF3h8kgWV4wDnHBe4foeeqwEm-69I38WmK3k,4176
343
343
  cirq/ops/permutation_gate_test.py,sha256=SwXRgsZNLn5jnGhfcKPJ0J0CIssNzElbFaqylV2TXD8,3281
344
344
  cirq/ops/phased_iswap_gate.py,sha256=8zRuD3uvMt4OFegD9zpEM-foJYbZEYBTIApShUk0BaI,8977
345
345
  cirq/ops/phased_iswap_gate_test.py,sha256=oH3RQ8tlSD0sU5Cf3M0uR92y3M1Xd7Yk3ayOoca9Neg,6708
@@ -1171,8 +1171,8 @@ cirq/work/sampler.py,sha256=JEAeQQRF3bqlO9AkOf4XbrTATDI5f5JgyM_FAUCNxao,19751
1171
1171
  cirq/work/sampler_test.py,sha256=B2ZsuqGT854gQtBIAh8k0LiG9Vj5wSzcGvkxOUoTcW4,13217
1172
1172
  cirq/work/zeros_sampler.py,sha256=x1C7cup66a43n-3tm8QjhiqJa07qcJW10FxNp9jJ59Q,2356
1173
1173
  cirq/work/zeros_sampler_test.py,sha256=JIkpBBFPJe5Ba4142vzogyWyboG1Q1ZAm0UVGgOoZn8,3279
1174
- cirq_core-1.4.0.dev20240509230054.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1175
- cirq_core-1.4.0.dev20240509230054.dist-info/METADATA,sha256=Mzmp1HmfU4Ar83IAGcjSvY3eRgNjH-Tl-SbzQqZH0g0,2000
1176
- cirq_core-1.4.0.dev20240509230054.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
1177
- cirq_core-1.4.0.dev20240509230054.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1178
- cirq_core-1.4.0.dev20240509230054.dist-info/RECORD,,
1174
+ cirq_core-1.4.0.dev20240510015550.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1175
+ cirq_core-1.4.0.dev20240510015550.dist-info/METADATA,sha256=9VtvG19gDwHKIu4N5LrMFuAEPpSOWLhaBPosZHAliA4,2000
1176
+ cirq_core-1.4.0.dev20240510015550.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
1177
+ cirq_core-1.4.0.dev20240510015550.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1178
+ cirq_core-1.4.0.dev20240510015550.dist-info/RECORD,,