cirq-core 1.6.0.dev20250613142538__py3-none-any.whl → 1.6.0.dev20250614001105__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.

Files changed (51) hide show
  1. cirq/__init__.py +8 -17
  2. cirq/_compat_test.py +2 -6
  3. cirq/_version.py +1 -1
  4. cirq/_version_test.py +1 -1
  5. cirq/circuits/circuit_operation_test.py +1 -1
  6. cirq/circuits/moment.py +0 -1
  7. cirq/contrib/acquaintance/bipartite_test.py +1 -1
  8. cirq/contrib/acquaintance/executor_test.py +1 -1
  9. cirq/contrib/acquaintance/shift.py +1 -1
  10. cirq/contrib/graph_device/graph_device.py +2 -2
  11. cirq/contrib/paulistring/clifford_target_gateset.py +1 -1
  12. cirq/contrib/qcircuit/qcircuit_test.py +2 -2
  13. cirq/contrib/routing/swap_network_test.py +1 -1
  14. cirq/experiments/__init__.py +1 -2
  15. cirq/interop/quirk/url_to_circuit_test.py +1 -1
  16. cirq/json_resolver_cache.py +1 -3
  17. cirq/linalg/__init__.py +4 -6
  18. cirq/ops/classically_controlled_operation_test.py +4 -12
  19. cirq/ops/clifford_gate_test.py +0 -1
  20. cirq/ops/fsim_gate_test.py +1 -3
  21. cirq/ops/pauli_gates_test.py +0 -2
  22. cirq/ops/pauli_string_test.py +1 -5
  23. cirq/ops/raw_types_test.py +2 -5
  24. cirq/ops/state_preparation_channel_test.py +1 -2
  25. cirq/protocols/__init__.py +0 -3
  26. cirq/protocols/measurement_key_protocol_test.py +0 -1
  27. cirq/protocols/pow_protocol.py +2 -4
  28. cirq/qis/clifford_tableau_test.py +0 -2
  29. cirq/testing/__init__.py +7 -11
  30. cirq/testing/circuit_compare.py +0 -12
  31. cirq/testing/consistent_act_on.py +0 -2
  32. cirq/testing/consistent_decomposition.py +0 -2
  33. cirq/testing/consistent_protocols.py +1 -7
  34. cirq/testing/consistent_specified_has_unitary.py +0 -2
  35. cirq/testing/equivalent_repr_eval.py +1 -1
  36. cirq/testing/lin_alg_utils.py +0 -2
  37. cirq/transformers/__init__.py +3 -4
  38. cirq/transformers/analytical_decompositions/__init__.py +3 -6
  39. cirq/transformers/dynamical_decoupling_test.py +2 -4
  40. cirq/transformers/merge_k_qubit_gates_test.py +4 -3
  41. cirq/transformers/optimize_for_target_gateset_test.py +2 -3
  42. cirq/transformers/transformer_primitives_test.py +5 -14
  43. cirq/value/linear_dict_test.py +5 -7
  44. cirq/value/measurement_key_test.py +0 -1
  45. cirq/value/timestamp_test.py +2 -3
  46. cirq/value/value_equality_attr.py +1 -1
  47. {cirq_core-1.6.0.dev20250613142538.dist-info → cirq_core-1.6.0.dev20250614001105.dist-info}/METADATA +1 -1
  48. {cirq_core-1.6.0.dev20250613142538.dist-info → cirq_core-1.6.0.dev20250614001105.dist-info}/RECORD +51 -51
  49. {cirq_core-1.6.0.dev20250613142538.dist-info → cirq_core-1.6.0.dev20250614001105.dist-info}/WHEEL +0 -0
  50. {cirq_core-1.6.0.dev20250613142538.dist-info → cirq_core-1.6.0.dev20250614001105.dist-info}/licenses/LICENSE +0 -0
  51. {cirq_core-1.6.0.dev20250613142538.dist-info → cirq_core-1.6.0.dev20250614001105.dist-info}/top_level.txt +0 -0
cirq/__init__.py CHANGED
@@ -123,20 +123,19 @@ from cirq.interop import (
123
123
  )
124
124
 
125
125
  from cirq.linalg import (
126
- # pylint: disable=line-too-long
127
126
  all_near_zero as all_near_zero,
128
127
  all_near_zero_mod as all_near_zero_mod,
129
128
  allclose_up_to_global_phase as allclose_up_to_global_phase,
130
129
  apply_matrix_to_slices as apply_matrix_to_slices,
131
130
  axis_angle as axis_angle,
132
131
  AxisAngleDecomposition as AxisAngleDecomposition,
133
- bidiagonalize_real_matrix_pair_with_symmetric_products as bidiagonalize_real_matrix_pair_with_symmetric_products,
134
- bidiagonalize_unitary_with_special_orthogonals as bidiagonalize_unitary_with_special_orthogonals,
132
+ bidiagonalize_real_matrix_pair_with_symmetric_products as bidiagonalize_real_matrix_pair_with_symmetric_products, # noqa: E501
133
+ bidiagonalize_unitary_with_special_orthogonals as bidiagonalize_unitary_with_special_orthogonals, # noqa: E501
135
134
  block_diag as block_diag,
136
135
  CONTROL_TAG as CONTROL_TAG,
137
136
  deconstruct_single_qubit_matrix_into_angles as deconstruct_single_qubit_matrix_into_angles,
138
137
  density_matrix_kronecker_product as density_matrix_kronecker_product,
139
- diagonalize_real_symmetric_and_sorted_diagonal_matrices as diagonalize_real_symmetric_and_sorted_diagonal_matrices,
138
+ diagonalize_real_symmetric_and_sorted_diagonal_matrices as diagonalize_real_symmetric_and_sorted_diagonal_matrices, # noqa: E501
140
139
  diagonalize_real_symmetric_matrix as diagonalize_real_symmetric_matrix,
141
140
  dot as dot,
142
141
  expand_matrix_in_orthogonal_basis as expand_matrix_in_orthogonal_basis,
@@ -165,7 +164,7 @@ from cirq.linalg import (
165
164
  partial_trace as partial_trace,
166
165
  partial_trace_of_state_vector_as_mixture as partial_trace_of_state_vector_as_mixture,
167
166
  PAULI_BASIS as PAULI_BASIS,
168
- scatter_plot_normalized_kak_interaction_coefficients as scatter_plot_normalized_kak_interaction_coefficients,
167
+ scatter_plot_normalized_kak_interaction_coefficients as scatter_plot_normalized_kak_interaction_coefficients, # noqa: E501
169
168
  pow_pauli_combination as pow_pauli_combination,
170
169
  reflection_matrix_pow as reflection_matrix_pow,
171
170
  slice_for_qubits_equal_to as slice_for_qubits_equal_to,
@@ -344,20 +343,19 @@ from cirq.ops import (
344
343
 
345
344
 
346
345
  from cirq.transformers import (
347
- # pylint: disable=line-too-long
348
346
  AbstractInitialMapper as AbstractInitialMapper,
349
347
  add_dynamical_decoupling as add_dynamical_decoupling,
350
348
  align_left as align_left,
351
349
  align_right as align_right,
352
350
  CompilationTargetGateset as CompilationTargetGateset,
353
351
  CZTargetGateset as CZTargetGateset,
354
- compute_cphase_exponents_for_fsim_decomposition as compute_cphase_exponents_for_fsim_decomposition,
352
+ compute_cphase_exponents_for_fsim_decomposition as compute_cphase_exponents_for_fsim_decomposition, # noqa: E501
355
353
  create_transformer_with_kwargs as create_transformer_with_kwargs,
356
354
  decompose_clifford_tableau_to_operations as decompose_clifford_tableau_to_operations,
357
355
  decompose_cphase_into_two_fsim as decompose_cphase_into_two_fsim,
358
356
  decompose_multi_controlled_x as decompose_multi_controlled_x,
359
357
  decompose_multi_controlled_rotation as decompose_multi_controlled_rotation,
360
- decompose_two_qubit_interaction_into_four_fsim_gates as decompose_two_qubit_interaction_into_four_fsim_gates,
358
+ decompose_two_qubit_interaction_into_four_fsim_gates as decompose_two_qubit_interaction_into_four_fsim_gates, # noqa: E501
361
359
  defer_measurements as defer_measurements,
362
360
  dephase_measurements as dephase_measurements,
363
361
  drop_empty_moments as drop_empty_moments,
@@ -408,7 +406,7 @@ from cirq.transformers import (
408
406
  transformer as transformer,
409
407
  two_qubit_matrix_to_cz_isometry as two_qubit_matrix_to_cz_isometry,
410
408
  two_qubit_matrix_to_cz_operations as two_qubit_matrix_to_cz_operations,
411
- two_qubit_matrix_to_diagonal_and_cz_operations as two_qubit_matrix_to_diagonal_and_cz_operations,
409
+ two_qubit_matrix_to_diagonal_and_cz_operations as two_qubit_matrix_to_diagonal_and_cz_operations, # noqa: E501
412
410
  two_qubit_matrix_to_ion_operations as two_qubit_matrix_to_ion_operations,
413
411
  two_qubit_matrix_to_sqrt_iswap_operations as two_qubit_matrix_to_sqrt_iswap_operations,
414
412
  two_qubit_gate_product_tabulation as two_qubit_gate_product_tabulation,
@@ -572,7 +570,6 @@ from cirq.value import (
572
570
  ProductState as ProductState,
573
571
  )
574
572
 
575
- # pylint: disable=redefined-builtin
576
573
  from cirq.protocols import (
577
574
  act_on as act_on,
578
575
  apply_channel as apply_channel,
@@ -694,14 +691,10 @@ from cirq.work import (
694
691
  ZerosSampler as ZerosSampler,
695
692
  )
696
693
 
697
- # pylint: enable=redefined-builtin
698
694
 
699
695
  # Unflattened sub-modules.
700
696
 
701
- from cirq import testing
702
-
703
697
  # Registers cirq-core's public classes for JSON serialization.
704
- # pylint: disable=wrong-import-position
705
698
  from cirq.protocols.json_serialization import _register_resolver
706
699
  from cirq.json_resolver_cache import _class_resolver_dictionary
707
700
 
@@ -710,6 +703,4 @@ _register_resolver(_class_resolver_dictionary)
710
703
 
711
704
  # contrib's json resolver cache depends on cirq.DEFAULT_RESOLVER
712
705
 
713
- from cirq import contrib
714
-
715
- # pylint: enable=wrong-import-position
706
+ from cirq import contrib # noqa: E402
cirq/_compat_test.py CHANGED
@@ -394,13 +394,11 @@ def test_deprecated_class():
394
394
  OldClass('1')
395
395
 
396
396
  with pytest.raises(AssertionError, match='deadline should match vX.Y'):
397
- # pylint: disable=unused-variable
397
+
398
398
  @deprecated_class(deadline='invalid', fix='theFix', name='foo')
399
399
  class BadlyDeprecatedClass(NewClass): # pragma: no cover
400
400
  ...
401
401
 
402
- # pylint: enable=unused-variable
403
-
404
402
 
405
403
  def _from_parent_import_deprecated():
406
404
  from cirq.testing._compat_test_data import fake_a
@@ -566,8 +564,7 @@ def _import_top_level_deprecated():
566
564
  def _repeated_import_path():
567
565
  """to ensure that the highly unlikely repeated subpath import doesn't interfere"""
568
566
 
569
- # pylint: disable=line-too-long
570
- from cirq.testing._compat_test_data.repeated_child.cirq.testing._compat_test_data.repeated_child import ( # type: ignore
567
+ from cirq.testing._compat_test_data.repeated_child.cirq.testing._compat_test_data.repeated_child import ( # type: ignore # noqa: E501
571
568
  child,
572
569
  )
573
570
 
@@ -812,7 +809,6 @@ def _test_broken_module_1_inner():
812
809
  with pytest.raises(
813
810
  DeprecatedModuleImportError, match="missing_module cannot be imported. The typical reasons"
814
811
  ):
815
- # pylint: disable=unused-import
816
812
  import cirq.testing._compat_test_data.broken_ref as br # type: ignore # noqa: F401
817
813
 
818
814
 
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.6.0.dev20250613142538"
31
+ __version__ = "1.6.0.dev20250614001105"
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.6.0.dev20250613142538"
6
+ assert cirq.__version__ == "1.6.0.dev20250614001105"
@@ -611,7 +611,7 @@ cirq.CircuitOperation(
611
611
  cirq.measure(cirq.LineQubit(0), cirq.LineQubit(1), cirq.LineQubit(2), key=cirq.MeasurementKey(name='m')),
612
612
  ),
613
613
  ]),
614
- )"""
614
+ )""" # noqa: E501
615
615
  )
616
616
 
617
617
  fc2 = cirq.FrozenCircuit(cirq.X(x), cirq.H(y), cirq.CX(y, x))
cirq/circuits/moment.py CHANGED
@@ -45,7 +45,6 @@ if TYPE_CHECKING:
45
45
 
46
46
  # Lazy imports to break circular dependencies.
47
47
  circuit = LazyLoader("circuit", globals(), "cirq.circuits.circuit")
48
- op_tree = LazyLoader("op_tree", globals(), "cirq.ops.op_tree")
49
48
  text_diagram_drawer = LazyLoader(
50
49
  "text_diagram_drawer", globals(), "cirq.circuits.text_diagram_drawer"
51
50
  )
@@ -203,7 +203,7 @@ circuit_diagrams = {
203
203
  │ │ │ │
204
204
  7: ─────────────────────────────────█───1↦0───────────────────────────────────────────────█───1↦0─────────────────────────────────
205
205
 
206
- """,
206
+ """, # noqa: E501
207
207
  (
208
208
  'decomposed',
209
209
  cca.BipartiteGraphType.MATCHING,
@@ -81,7 +81,7 @@ def test_executor_explicit():
81
81
  6: ───6───7───╲0╱───7───4───╱1╲───4───6───╲0╱───6───2───╱1╲───2───4───╲0╱───4───0───╱1╲───0───2───╲0╱───2───1───╱1╲───
82
82
  │ │ │ │ │ │ │ │ │ │ │ │
83
83
  7: ───7───6───╱1╲─────────────────6───4───╱1╲─────────────────4───2───╱1╲─────────────────2───0───╱1╲─────────────────
84
- """.strip()
84
+ """.strip() # noqa: E501
85
85
  ct.assert_has_diagram(circuit, expected_text_diagram)
86
86
 
87
87
 
@@ -36,7 +36,7 @@ class CircularShiftGate(PermutationGate):
36
36
  shift: The number of positions to circularly left shift the qubits.
37
37
  swap_gate: The gate to use when decomposing.
38
38
  """
39
- super(CircularShiftGate, self).__init__(num_qubits, swap_gate)
39
+ super().__init__(num_qubits, swap_gate)
40
40
  self.shift = shift
41
41
 
42
42
  def __repr__(self) -> str:
@@ -174,8 +174,8 @@ class UndirectedGraphDevice(devices.Device):
174
174
  device_edge = self.get_device_edge_from_op(operation)
175
175
  except Exception as error:
176
176
  if frozenset(operation.qubits) not in self.device_graph.edges:
177
- error = ValueError(f'{operation.qubits} not in device graph edges')
178
- raise error
177
+ raise ValueError(f'{operation.qubits} not in device graph edges') from error
178
+ raise # pragma: no cover
179
179
  device_edge.validate_operation(operation)
180
180
 
181
181
  def validate_crosstalk(
@@ -79,7 +79,7 @@ class CliffordTargetGateset(transformers.TwoQubitCompilationTargetGateset):
79
79
  def __init__(
80
80
  self,
81
81
  *,
82
- single_qubit_target: SingleQubitTarget = SingleQubitTarget.PAULI_STRING_PHASORS_AND_CLIFFORDS, # pylint: disable=line-too-long
82
+ single_qubit_target: SingleQubitTarget = SingleQubitTarget.PAULI_STRING_PHASORS_AND_CLIFFORDS, # noqa: E501
83
83
  atol: float = 1e-8,
84
84
  ):
85
85
  """Initializes CliffordTargetGateset
@@ -102,7 +102,7 @@ def test_teleportation_diagram() -> None:
102
102
  &\lstick{\text{carrier}}& \qw&\gate{\text{H}} \qw&\control \qw &\targ \qw\qwx&\meter \qw&\control \qw & \qw\qwx&\qw\\
103
103
  &\lstick{\text{bob}}& \qw& \qw&\targ \qw\qwx& \qw & \qw&\targ \qw\qwx&\control \qw\qwx&\qw\\
104
104
  \\
105
- }""".strip()
105
+ }""".strip() # noqa: E501
106
106
  assert_has_qcircuit_diagram(
107
107
  circuit, expected_diagram, qubit_order=cirq.QubitOrder.explicit([ali, car, bob])
108
108
  )
@@ -151,7 +151,7 @@ def test_two_cx_diagram() -> None:
151
151
  &\lstick{\text{q(2)}}& \qw&\targ \qw\qwx& \qw\qwx&\targ \qw\qwx& \qw\qwx&\qw\\
152
152
  &\lstick{\text{q(3)}}& \qw& \qw &\targ \qw\qwx& \qw &\targ \qw\qwx&\qw\\
153
153
  \\
154
- }""".strip()
154
+ }""".strip() # noqa: E501
155
155
  assert_has_qcircuit_diagram(circuit, expected_diagram)
156
156
 
157
157
 
@@ -81,5 +81,5 @@ def test_swap_network_str():
81
81
  (3, 0): ───q(3)───ZZ───q(3)───╱1╲───q(2)───ZZ───q(2)───╲0╱───q(4)───ZZ───q(4)───╱1╲───q(0)───ZZ───q(0)───╲0╱───q(2)───ZZ───q(2)───╱1╲───q(1)───
82
82
  │ │ │ │
83
83
  (4, 0): ───q(4)────────q(4)─────────q(4)───ZZ───q(4)───╱1╲───q(2)────────q(2)─────────q(2)───ZZ───q(2)───╱1╲───q(0)────────q(0)─────────q(0)───
84
- """.strip()
84
+ """.strip() # noqa: E501
85
85
  assert actual_str == expected_str
@@ -37,12 +37,11 @@ from cirq.experiments.purity_estimation import (
37
37
  )
38
38
 
39
39
  from cirq.experiments.random_quantum_circuit_generation import (
40
- # pylint: disable=line-too-long
41
40
  GRID_ALIGNED_PATTERN as GRID_ALIGNED_PATTERN,
42
41
  GRID_STAGGERED_PATTERN as GRID_STAGGERED_PATTERN,
43
42
  HALF_GRID_STAGGERED_PATTERN as HALF_GRID_STAGGERED_PATTERN,
44
43
  GridInteractionLayer as GridInteractionLayer,
45
- random_rotations_between_grid_interaction_layers_circuit as random_rotations_between_grid_interaction_layers_circuit,
44
+ random_rotations_between_grid_interaction_layers_circuit as random_rotations_between_grid_interaction_layers_circuit, # noqa: E501
46
45
  )
47
46
 
48
47
  from cirq.experiments.readout_confusion_matrix import (
@@ -356,7 +356,7 @@ def test_example_qft_circuit():
356
356
  6: ───┼───×─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────@^0.016───@^0.031───@^(1/16)───@^(1/8)───@^0.25───@^0.5───H───┼─────────┼─────────┼─────────┼──────────┼─────────┼────────@───────────
357
357
  │ │ │ │ │ │ │ │
358
358
  7: ───×───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────@^0.008───@^0.016───@^0.031───@^(1/16)───@^(1/8)───@^0.25───@^0.5───H───
359
- """
359
+ """ # noqa: E501
360
360
 
361
361
  qft_example_json = (
362
362
  '{"cols":['
@@ -237,9 +237,7 @@ def _class_resolver_dictionary() -> dict[str, ObjectFactory]:
237
237
  'VirtualTag': cirq.VirtualTag,
238
238
  'WaitGate': cirq.WaitGate,
239
239
  # The formatter keeps putting this back
240
- # pylint: disable=line-too-long
241
- 'XEBPhasedFSimCharacterizationOptions': cirq.experiments.XEBPhasedFSimCharacterizationOptions,
242
- # pylint: enable=line-too-long
240
+ 'XEBPhasedFSimCharacterizationOptions': cirq.experiments.XEBPhasedFSimCharacterizationOptions, # noqa: E501
243
241
  '_XEigenState': cirq.value.product_state._XEigenState,
244
242
  'XPowGate': cirq.XPowGate,
245
243
  'XXPowGate': cirq.XXPowGate,
cirq/linalg/__init__.py CHANGED
@@ -26,7 +26,6 @@ from cirq.linalg.combinators import (
26
26
  )
27
27
 
28
28
  from cirq.linalg.decompositions import (
29
- # pylint: disable=line-too-long
30
29
  axis_angle as axis_angle,
31
30
  AxisAngleDecomposition as AxisAngleDecomposition,
32
31
  deconstruct_single_qubit_matrix_into_angles as deconstruct_single_qubit_matrix_into_angles,
@@ -39,15 +38,14 @@ from cirq.linalg.decompositions import (
39
38
  map_eigenvalues as map_eigenvalues,
40
39
  num_cnots_required as num_cnots_required,
41
40
  unitary_eig as unitary_eig,
42
- scatter_plot_normalized_kak_interaction_coefficients as scatter_plot_normalized_kak_interaction_coefficients,
41
+ scatter_plot_normalized_kak_interaction_coefficients as scatter_plot_normalized_kak_interaction_coefficients, # noqa: E501
43
42
  so4_to_magic_su2s as so4_to_magic_su2s,
44
43
  )
45
44
 
46
45
  from cirq.linalg.diagonalize import (
47
- # pylint: disable=line-too-long
48
- bidiagonalize_real_matrix_pair_with_symmetric_products as bidiagonalize_real_matrix_pair_with_symmetric_products,
49
- bidiagonalize_unitary_with_special_orthogonals as bidiagonalize_unitary_with_special_orthogonals,
50
- diagonalize_real_symmetric_and_sorted_diagonal_matrices as diagonalize_real_symmetric_and_sorted_diagonal_matrices,
46
+ bidiagonalize_real_matrix_pair_with_symmetric_products as bidiagonalize_real_matrix_pair_with_symmetric_products, # noqa: E501
47
+ bidiagonalize_unitary_with_special_orthogonals as bidiagonalize_unitary_with_special_orthogonals, # noqa: E501
48
+ diagonalize_real_symmetric_and_sorted_diagonal_matrices as diagonalize_real_symmetric_and_sorted_diagonal_matrices, # noqa: E501
51
49
  diagonalize_real_symmetric_matrix as diagonalize_real_symmetric_matrix,
52
50
  )
53
51
 
@@ -505,17 +505,15 @@ def test_scope_local() -> None:
505
505
  assert internal_control_keys == ['0:0:a', '0:1:a', '1:0:a', '1:1:a']
506
506
  assert not cirq.control_keys(outer_subcircuit)
507
507
  assert not cirq.control_keys(circuit)
508
- # pylint: disable=line-too-long
509
508
  cirq.testing.assert_has_diagram(
510
509
  cirq.Circuit(outer_subcircuit),
511
510
  """
512
511
  [ [ 0: ───M───X─── ] ]
513
512
  0: ───[ 0: ───[ ║ ║ ]───────────────────────────────────── ]─────────────────────────────────────
514
513
  [ [ a: ═══@═══^═══ ](loops=2, use_repetition_ids=True) ](loops=2, use_repetition_ids=True)
515
- """,
514
+ """, # noqa: E501
516
515
  use_unicode_characters=True,
517
516
  )
518
- # pylint: enable=line-too-long
519
517
  cirq.testing.assert_has_diagram(
520
518
  circuit,
521
519
  """
@@ -659,7 +657,6 @@ def test_scope_extern() -> None:
659
657
  assert internal_control_keys == ['0:b', '0:b', '1:b', '1:b']
660
658
  assert not cirq.control_keys(outer_subcircuit)
661
659
  assert not cirq.control_keys(circuit)
662
- # pylint: disable=line-too-long
663
660
  cirq.testing.assert_has_diagram(
664
661
  cirq.Circuit(outer_subcircuit),
665
662
  """
@@ -668,10 +665,9 @@ def test_scope_extern() -> None:
668
665
  0: ───[ ║ [ b: ════════════^═══ ](loops=2, use_repetition_ids=True) ]─────────────────────────────────────
669
666
  [ ║ ║ ]
670
667
  [ b: ═══@═══╩═══════════════════════════════════════════════════════════ ](loops=2, use_repetition_ids=True)
671
- """,
668
+ """, # noqa: E501
672
669
  use_unicode_characters=True,
673
670
  )
674
- # pylint: enable=line-too-long
675
671
  cirq.testing.assert_has_diagram(
676
672
  circuit,
677
673
  """
@@ -780,7 +776,6 @@ def test_scope_extern_mismatch() -> None:
780
776
  assert internal_control_keys == ['b', 'b', 'b', 'b']
781
777
  assert cirq.control_keys(outer_subcircuit) == {cirq.MeasurementKey('b')}
782
778
  assert cirq.control_keys(circuit) == {cirq.MeasurementKey('b')}
783
- # pylint: disable=line-too-long
784
779
  cirq.testing.assert_has_diagram(
785
780
  cirq.Circuit(outer_subcircuit),
786
781
  """
@@ -791,10 +786,9 @@ def test_scope_extern_mismatch() -> None:
791
786
  [ b: ══════════════╩═══════════════════════════════════════════════════════════ ](loops=2, use_repetition_ids=True)
792
787
 
793
788
  b: ═══╩═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
794
- """,
789
+ """, # noqa: E501
795
790
  use_unicode_characters=True,
796
791
  )
797
- # pylint: enable=line-too-long
798
792
  cirq.testing.assert_has_diagram(
799
793
  circuit,
800
794
  """
@@ -984,7 +978,6 @@ d: ═══╩═════════════════════
984
978
  use_unicode_characters=True,
985
979
  )
986
980
 
987
- # pylint: disable=line-too-long
988
981
  cirq.testing.assert_has_diagram(
989
982
  circuit,
990
983
  """
@@ -997,10 +990,9 @@ b: ═══@══════════════════^════
997
990
  c: ══════════════════════^══════════════════════════════════^═════════════════════════════════════════════════^══════════════════════════════════^══════════════════════════════
998
991
  ║ ║ ║ ║
999
992
  d: ══════════════════════^══════════════════════════════════^═════════════════════════════════════════════════^══════════════════════════════════^══════════════════════════════
1000
- """,
993
+ """, # noqa: E501
1001
994
  use_unicode_characters=True,
1002
995
  )
1003
- # pylint: enable=line-too-long
1004
996
 
1005
997
 
1006
998
  def test_sympy_scope_simulation() -> None:
@@ -125,7 +125,6 @@ def test_init_from_double_invalid(trans1, from1) -> None:
125
125
  @pytest.mark.parametrize('trans,frm', itertools.product(_all_rotations(), _paulis))
126
126
  def test_init_from_single_map_vs_kwargs(trans, frm) -> None:
127
127
  from_str = str(frm).lower() + '_to'
128
- # pylint: disable=unexpected-keyword-arg
129
128
  gate_kw = cirq.SingleQubitCliffordGate.from_single_map(**{from_str: trans})
130
129
  gate_map = cirq.SingleQubitCliffordGate.from_single_map({frm: trans})
131
130
  assert gate_kw == gate_map
@@ -490,7 +490,6 @@ def test_phased_fsim_circuit() -> None:
490
490
  1: ───PhFSim(0.5π, -π, 0.5π, 0, -0.25π)───PhFSim(-π, 0.5π, 0.1π, 0.2π, 0.3π)───
491
491
  """,
492
492
  )
493
- # pylint: disable=line-too-long
494
493
  cirq.testing.assert_has_diagram(
495
494
  c,
496
495
  """
@@ -506,11 +505,10 @@ def test_phased_fsim_circuit() -> None:
506
505
  0: ---PhFSim(1.5707963267948966, -pi, 1.5707963267948966, 0, -0.7853981633974483)---PhFSim(-pi, 1.5707963267948966, 0.3141592653589793, 0.6283185307179586, 0.9424777960769379)---
507
506
  | |
508
507
  1: ---PhFSim(1.5707963267948966, -pi, 1.5707963267948966, 0, -0.7853981633974483)---PhFSim(-pi, 1.5707963267948966, 0.3141592653589793, 0.6283185307179586, 0.9424777960769379)---
509
- """,
508
+ """, # noqa: E501
510
509
  use_unicode_characters=False,
511
510
  precision=None,
512
511
  )
513
- # pylint: enable=line-too-long
514
512
  c = cirq.Circuit(
515
513
  cirq.PhasedFSimGate(
516
514
  sympy.Symbol('a') + sympy.Symbol('b'),
@@ -116,7 +116,6 @@ def test_relative_index_consistency() -> None:
116
116
 
117
117
 
118
118
  def test_gt() -> None:
119
- # pylint: disable=unnecessary-negation
120
119
  assert not cirq.X > cirq.X
121
120
  assert not cirq.X > cirq.Y
122
121
  assert cirq.X > cirq.Z
@@ -134,7 +133,6 @@ def test_gt_other_type() -> None:
134
133
 
135
134
 
136
135
  def test_lt() -> None:
137
- # pylint: disable=unnecessary-negation
138
136
  assert not cirq.X < cirq.X
139
137
  assert cirq.X < cirq.Y
140
138
  assert not cirq.X < cirq.Z
@@ -1546,7 +1546,6 @@ def test_pretty_print():
1546
1546
  assert p.text_pretty == 'cirq.PauliString(...)'
1547
1547
 
1548
1548
 
1549
- # pylint: disable=line-too-long
1550
1549
  def test_circuit_diagram_info():
1551
1550
  a, b, c = cirq.LineQubit.range(3)
1552
1551
 
@@ -1567,13 +1566,10 @@ def test_circuit_diagram_info():
1567
1566
  1: ───────────────────────────────────────┼─────────────────Y─────────────────PauliString(-iY)───Y───────────────────────────────
1568
1567
 
1569
1568
  2: ───────────────────────────────────────Z──────────────────────────────────────────────────────────────────────────────────────
1570
- """,
1569
+ """, # noqa: E501
1571
1570
  )
1572
1571
 
1573
1572
 
1574
- # pylint: enable=line-too-long
1575
-
1576
-
1577
1573
  def test_mutable_pauli_string_init_raises():
1578
1574
  q = cirq.LineQubit.range(3)
1579
1575
  with pytest.raises(ValueError, match='must be between 1 and 3'):
@@ -79,8 +79,7 @@ def test_wrapped_qid() -> None:
79
79
  'dimension': 3,
80
80
  }
81
81
 
82
- # pylint: disable=unnecessary-negation
83
- assert not ValidQubit('zz') == 4
82
+ assert not ValidQubit('zz') == 4 # noqa: SIM201
84
83
  assert ValidQubit('zz') != 4
85
84
  assert ValidQubit('zz') > ValidQubit('aa')
86
85
  assert ValidQubit('zz') <= ValidQubit('zz')
@@ -786,9 +785,7 @@ def test_inverse_composite_standards() -> None:
786
785
  def _is_parameterized_(self) -> bool:
787
786
  return cirq.is_parameterized(self._param)
788
787
 
789
- def _resolve_parameters_(
790
- self, resolver: cirq.ParamResolver, recursive: bool
791
- ) -> Gate: # pylint: disable=undefined-variable
788
+ def _resolve_parameters_(self, resolver: cirq.ParamResolver, recursive: bool) -> Gate:
792
789
  return Gate(cirq.resolve_parameters(self._param, resolver, recursive))
793
790
 
794
791
  def __repr__(self):
@@ -124,12 +124,11 @@ def test_gate_error_handling() -> None:
124
124
 
125
125
 
126
126
  def test_equality_of_gates() -> None:
127
- # pylint: disable=unnecessary-negation
128
127
  state = np.array([1, 0, 0, 0], dtype=np.complex64)
129
128
  gate_1 = cirq.StatePreparationChannel(state)
130
129
  gate_2 = cirq.StatePreparationChannel(state)
131
130
  assert gate_1 == gate_2, "Equal state not leading to same gate"
132
- assert not gate_1 == state, "Incompatible objects shouldn't be equal"
131
+ assert not gate_1 == state, "Incompatible objects shouldn't be equal" # noqa: SIM201
133
132
  state = np.array([0, 1, 0, 0], dtype=np.complex64)
134
133
  gate_3 = cirq.StatePreparationChannel(state, name='gate_a')
135
134
  gate_4 = cirq.StatePreparationChannel(state, name='gate_b')
@@ -139,11 +139,8 @@ from cirq.protocols.pauli_expansion_protocol import (
139
139
  SupportsPauliExpansion as SupportsPauliExpansion,
140
140
  )
141
141
 
142
- # pylint: disable=redefined-builtin
143
142
  from cirq.protocols.pow_protocol import pow as pow
144
143
 
145
- # pylint: enable=redefined-builtin
146
-
147
144
  from cirq.protocols.qasm import (
148
145
  qasm as qasm,
149
146
  QasmArgs as QasmArgs,
@@ -101,7 +101,6 @@ def test_is_measurement() -> None:
101
101
  assert not cirq.is_measurement(cirq.bit_flip(1))
102
102
 
103
103
  class NotImplementedOperation(cirq.Operation):
104
- # pylint: disable=undefined-variable
105
104
  def with_qubits(self, *new_qubits) -> NotImplementedOperation:
106
105
  raise NotImplementedError()
107
106
 
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ # ruff: noqa: A001
16
+
15
17
  from __future__ import annotations
16
18
 
17
19
  from typing import Any, Callable, overload, TYPE_CHECKING, TypeVar
@@ -26,7 +28,6 @@ RaiseTypeErrorIfNotProvided: Any = ([],)
26
28
  TDefault = TypeVar('TDefault')
27
29
 
28
30
 
29
- # pylint: disable=redefined-builtin
30
31
  @overload
31
32
  def pow(val: cirq.Gate, exponent: Any) -> cirq.Gate:
32
33
  pass
@@ -57,9 +58,6 @@ def pow(val: Any, exponent: Any, default: TDefault) -> Any:
57
58
  pass
58
59
 
59
60
 
60
- # pylint: enable=redefined-builtin
61
-
62
-
63
61
  def pow(val: Any, exponent: Any, default: Any = RaiseTypeErrorIfNotProvided) -> Any:
64
62
  """Returns `val**factor` of the given value, if defined.
65
63
 
@@ -440,9 +440,7 @@ def test_tableau_matmul():
440
440
  assert expected_t != t1 @ t2
441
441
 
442
442
  with pytest.raises(TypeError):
443
- # pylint: disable=pointless-statement
444
443
  t1 @ 21
445
- # pylint: enable=pointless-statement
446
444
 
447
445
 
448
446
  def test_tableau_then_with_bad_input():
cirq/testing/__init__.py CHANGED
@@ -15,12 +15,11 @@
15
15
  """Utilities for testing code."""
16
16
 
17
17
  from cirq.testing.circuit_compare import (
18
- # pylint: disable=line-too-long
19
- assert_circuits_with_terminal_measurements_are_equivalent as assert_circuits_with_terminal_measurements_are_equivalent,
20
- assert_circuits_have_same_unitary_given_final_permutation as assert_circuits_have_same_unitary_given_final_permutation,
18
+ assert_circuits_with_terminal_measurements_are_equivalent as assert_circuits_with_terminal_measurements_are_equivalent, # noqa: E501
19
+ assert_circuits_have_same_unitary_given_final_permutation as assert_circuits_have_same_unitary_given_final_permutation, # noqa: E501
21
20
  assert_has_consistent_apply_channel as assert_has_consistent_apply_channel,
22
21
  assert_has_consistent_apply_unitary as assert_has_consistent_apply_unitary,
23
- assert_has_consistent_apply_unitary_for_various_exponents as assert_has_consistent_apply_unitary_for_various_exponents,
22
+ assert_has_consistent_apply_unitary_for_various_exponents as assert_has_consistent_apply_unitary_for_various_exponents, # noqa: E501
24
23
  assert_has_diagram as assert_has_diagram,
25
24
  assert_same_circuits as assert_same_circuits,
26
25
  highlight_text_differences as highlight_text_differences,
@@ -28,8 +27,7 @@ from cirq.testing.circuit_compare import (
28
27
  )
29
28
 
30
29
  from cirq.testing.consistent_act_on import (
31
- # pylint: disable=line-too-long
32
- assert_all_implemented_act_on_effects_match_unitary as assert_all_implemented_act_on_effects_match_unitary,
30
+ assert_all_implemented_act_on_effects_match_unitary as assert_all_implemented_act_on_effects_match_unitary, # noqa: E501
33
31
  )
34
32
 
35
33
  from cirq.testing.consistent_channels import (
@@ -48,8 +46,7 @@ from cirq.testing.consistent_decomposition import (
48
46
  )
49
47
 
50
48
  from cirq.testing.consistent_pauli_expansion import (
51
- # pylint: disable=line-too-long
52
- assert_pauli_expansion_is_consistent_with_unitary as assert_pauli_expansion_is_consistent_with_unitary,
49
+ assert_pauli_expansion_is_consistent_with_unitary as assert_pauli_expansion_is_consistent_with_unitary, # noqa: E501
53
50
  )
54
51
 
55
52
  from cirq.testing.consistent_phase_by import (
@@ -57,11 +54,10 @@ from cirq.testing.consistent_phase_by import (
57
54
  )
58
55
 
59
56
  from cirq.testing.consistent_protocols import (
60
- # pylint: disable=line-too-long
61
- assert_eigengate_implements_consistent_protocols as assert_eigengate_implements_consistent_protocols,
57
+ assert_eigengate_implements_consistent_protocols as assert_eigengate_implements_consistent_protocols, # noqa: E501
62
58
  assert_has_consistent_trace_distance_bound as assert_has_consistent_trace_distance_bound,
63
59
  assert_implements_consistent_protocols as assert_implements_consistent_protocols,
64
- assert_commutes_magic_method_consistent_with_unitaries as assert_commutes_magic_method_consistent_with_unitaries,
60
+ assert_commutes_magic_method_consistent_with_unitaries as assert_commutes_magic_method_consistent_with_unitaries, # noqa: E501
65
61
  )
66
62
 
67
63
  from cirq.testing.consistent_qasm import (