Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cirq-aqt/cirq_aqt/aqt_device_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def __init__(
cirq.GateFamily(cirq.ZPowGate): self._oneq_gates_duration,
cirq.GateFamily(cirq.PhasedXPowGate): self._oneq_gates_duration,
}
assert not self._gateset.gates.symmetric_difference(self._gate_durations.keys()), (
"AQTDeviceMetadata.gate_durations must have the same Gates " "as AQTTargetGateset."
)
assert not self._gateset.gates.symmetric_difference(
self._gate_durations.keys()
), "AQTDeviceMetadata.gate_durations must have the same Gates as AQTTargetGateset."

@property
def gateset(self) -> cirq.Gateset:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_repr() -> None:

assert repr(gate) == (
"cirq.BayesianNetworkGate(init_probs=[('q0', 0.0), ('q1', None)],"
+ " arc_probs=[('q1', ('q0',), [0.0, 0.0])])"
" arc_probs=[('q1', ('q0',), [0.0, 0.0])])"
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -814,8 +814,7 @@ def test_group_paulis_are_not_qwc() -> None:
circuits_to_pauli: dict[cirq.FrozenCircuit, list[cirq.PauliString]] = {}
circuits_to_pauli[circuit] = [[pauli_str1, pauli_str2]] # type: ignore
with pytest.raises(
ValueError,
match="The group of Pauli strings are not " "Qubit-Wise Commuting with each other.",
ValueError, match="The group of Pauli strings are not Qubit-Wise Commuting with each other."
):
measure_pauli_strings(
circuits_to_pauli, cirq.Simulator(), 1000, 1000, 1000, np.random.default_rng()
Expand Down
4 changes: 2 additions & 2 deletions cirq-core/cirq/devices/insertion_noise_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def noisy_moment(self, moment: cirq.Moment, system_qubits: Sequence[cirq.Qid]) -
def __repr__(self) -> str:
return (
f'cirq.devices.InsertionNoiseModel(ops_added={self.ops_added},'
+ f' prepend={self.prepend},'
+ f' require_physical_tag={self.require_physical_tag})'
f' prepend={self.prepend},'
f' require_physical_tag={self.require_physical_tag})'
)

def _json_dict_(self) -> dict[str, Any]:
Expand Down
4 changes: 2 additions & 2 deletions cirq-core/cirq/experiments/readout_confusion_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ def readout_mitigation_pauli_uncorrelated(
idx = self.measure_qubits.index((qubit,))
except: # pragma: no cover
raise NotImplementedError(
"The response matrix must be a tensor product of single-qu"
+ f"bit response matrices, including that of qubit {qubit}."
"The response matrix must be a tensor product of single-qubit "
f"response matrices, including that of qubit {qubit}."
)
cm_all.append(self.confusion_matrices[idx])

Expand Down
4 changes: 2 additions & 2 deletions cirq-core/cirq/ops/common_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def _circuit_diagram_info_(self, args: protocols.CircuitDiagramInfoArgs) -> str
if args.precision is not None:
return (
f"A({self.p_x:.{args.precision}g},"
+ f"{self.p_y:.{args.precision}g},"
+ f"{self.p_z:.{args.precision}g})"
f"{self.p_y:.{args.precision}g},"
f"{self.p_z:.{args.precision}g})"
)
return f"A({self.p_x},{self.p_y},{self.p_z})"
if args.precision is not None:
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/common_channels_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_asymmetric_depolarizing_channel_str() -> None:
assert (
str(cirq.asymmetric_depolarize(0.1, 0.2, 0.3))
== "asymmetric_depolarize(error_probabilities={'I': 0.3999999999999999, "
+ "'X': 0.1, 'Y': 0.2, 'Z': 0.3})"
"'X': 0.1, 'Y': 0.2, 'Z': 0.3})"
)


Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/projector.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def expectation_from_density_matrix(
def __repr__(self) -> str:
return (
f"cirq.ProjectorString(projector_dict={self._projector_dict},"
+ f"coefficient={self._coefficient})"
f"coefficient={self._coefficient})"
)

def _json_dict_(self) -> dict[str, Any]:
Expand Down
4 changes: 1 addition & 3 deletions cirq-core/cirq/protocols/json_serialization_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,7 @@ def custom_resolver(name):

sto = SerializableTypeObject(cls)
test_resolvers = [custom_resolver] + cirq.DEFAULT_RESOLVERS
expected_json = (
f'{{\n "cirq_type": "SerializableTypeObject",\n' f' "test_type": "{typename}"\n}}'
)
expected_json = f'{{\n "cirq_type": "SerializableTypeObject",\n "test_type": "{typename}"\n}}'
assert cirq.to_json(sto) == expected_json
assert cirq.read_json(json_text=expected_json, resolvers=test_resolvers) == sto
assert_json_roundtrip_works(sto, resolvers=test_resolvers)
Expand Down
6 changes: 3 additions & 3 deletions cirq-core/cirq/sim/clifford/clifford_simulator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def test_clifford_trial_result_repr_pretty():
final_simulator_state=final_simulator_state,
)

cirq.testing.assert_repr_pretty(result, "measurements: m=1\n" "output state: |0⟩")
cirq.testing.assert_repr_pretty(result, "measurements: m=1\noutput state: |0⟩")
cirq.testing.assert_repr_pretty(result, "cirq.CliffordTrialResult(...)", cycle=True)


Expand All @@ -285,15 +285,15 @@ def test_clifford_step_result_str():
result = next(
cirq.CliffordSimulator().simulate_moment_steps(cirq.Circuit(cirq.measure(q0, key='m')))
)
assert str(result) == "m=0\n" "|0⟩"
assert str(result) == "m=0\n|0⟩"


def test_clifford_step_result_repr_pretty():
q0 = cirq.LineQubit(0)
result = next(
cirq.CliffordSimulator().simulate_moment_steps(cirq.Circuit(cirq.measure(q0, key='m')))
)
cirq.testing.assert_repr_pretty(result, "m=0\n" "|0⟩")
cirq.testing.assert_repr_pretty(result, "m=0\n|0⟩")
cirq.testing.assert_repr_pretty(result, "cirq.CliffordSimulatorStateResult(...)", cycle=True)


Expand Down
3 changes: 1 addition & 2 deletions cirq-core/cirq/testing/equivalent_basis_map_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ def test_correct_mappings() -> None:
def test_incorrect_mappings() -> None:
a, b, c = cirq.LineQubit.range(3)
with pytest.raises(
AssertionError,
match=r"0b001 \(1\) was mapped to " r"0b100 \(4\) instead of " r"0b010 \(2\)",
AssertionError, match=r"0b001 \(1\) was mapped to 0b100 \(4\) instead of 0b010 \(2\)"
):
cirq.testing.assert_equivalent_computational_basis_map(
maps={0b001: 0b010, 0b010: 0b100, 0b100: 0b001},
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/transformers/noise_adding.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(
if not isinstance(p, (Mapping, float)):
raise TypeError( # pragma: no cover
"p must either be a float or a mapping from" # pragma: no cover
+ "sorted qubit pairs to floats" # pragma: no cover
"sorted qubit pairs to floats" # pragma: no cover
) # pragma: no cover
self.p = p
self.p_func = (
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/value/product_state_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_product_state():
with pytest.raises(ValueError) as e:
# Re-use q2
ps *= cirq.KET_PLUS(q2)
assert e.match(r'.*both contain factors for these qubits: ' r'\[cirq.LineQubit\(2\)\]')
assert e.match(r'.*both contain factors for these qubits: \[cirq.LineQubit\(2\)\]')

ps2 = eval(repr(ps))
assert ps == ps2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,11 @@ def __init__(
# transport is a QuantumEngineServiceTransport instance.
if credentials or client_options.credentials_file or api_key_value:
raise ValueError(
"When providing a transport instance, " "provide its credentials directly."
"When providing a transport instance, provide its credentials directly."
)
if client_options.scopes:
raise ValueError(
"When providing a transport instance, provide its scopes " "directly."
"When providing a transport instance, provide its scopes directly."
)
self._transport = transport
else:
Expand Down
8 changes: 4 additions & 4 deletions cirq-google/cirq_google/engine/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def heatmap(self, key: str) -> cirq.Heatmap:
if not all(len(k) == 1 for k in metrics.values()):
raise ValueError(
'Heatmaps are only supported if all values in a metric are single metric values.'
+ f'{key} has metric values {metrics.values()}'
f'{key} has metric values {metrics.values()}'
)
value_map = {self.key_to_qubits(k): self.value_to_float(v) for k, v in metrics.items()}
if all(len(k) == 1 for k in value_map.keys()):
Expand All @@ -252,7 +252,7 @@ def heatmap(self, key: str) -> cirq.Heatmap:
return cirq.TwoQubitInteractionHeatmap(value_map, title=key.replace('_', ' ').title())
raise ValueError(
'Heatmaps are only supported if all the targets in a metric are one or two qubits.'
+ f'{key} has target qubits {value_map.keys()}'
f'{key} has target qubits {value_map.keys()}'
)

def plot_histograms(
Expand Down Expand Up @@ -289,8 +289,8 @@ def plot_histograms(
if not all(len(k) == 1 for k in metrics.values()):
raise ValueError(
'Histograms are only supported if all values in a metric '
+ 'are single metric values.'
+ f'{key} has metric values {metrics.values()}'
'are single metric values.'
f'{key} has metric values {metrics.values()}'
)
cirq.integrated_histogram(
[self.value_to_float(v) for v in metrics.values()],
Expand Down
2 changes: 1 addition & 1 deletion cirq-google/cirq_google/engine/engine_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ def test_list_jobs(client_constructor, default_engine_client):
None,
),
(
'(execution_status.state = FAILURE OR ' 'execution_status.state = CANCELLED)',
'(execution_status.state = FAILURE OR execution_status.state = CANCELLED)',
None,
None,
None,
Expand Down
2 changes: 1 addition & 1 deletion cirq-google/cirq_google/engine/qcs_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,6 @@ def authenticate_user(clear_output: bool = False) -> None:
except Exception as exc:
print(
"Authentication failed, you may not have permission to access a"
+ " hardware Engine. Use a virtual Engine instead."
" hardware Engine. Use a virtual Engine instead."
)
raise exc
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ def _deserialize_gate_op(
)
if sub_gate is None or sub_gate.gate is None:
raise ValueError(
"Not a valid gate for RandomGateChannel: " f"{operation_proto}"
f"Not a valid gate for RandomGateChannel: {operation_proto}"
) # pragma: nocover
op = cirq.RandomGateChannel(probability=p, sub_gate=sub_gate.gate)(*qubits)
else:
Expand Down
4 changes: 1 addition & 3 deletions examples/advanced/quantum_volume.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@
" sampler['probabilities'][depth] /= num_repetitions\n",
" sampler['routed-probabilities'][depth] /= num_repetitions\n",
" sampler['compiled-probabilities'][depth] /= num_repetitions\n",
" print(\n",
" f\" Average {sampler['label']} HOG probability: \" f\"{sampler['probabilities'][depth]}\"\n",
" )\n",
" print(f\" Average {sampler['label']} HOG probability: {sampler['probabilities'][depth]}\")\n",
" print(\n",
" f\" Average {sampler['label']} optimized HOG probability: \"\n",
" f\"{sampler['routed-probabilities'][depth]}\"\n",
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ select = [
"F811", # redefined-while-unused, pylint function-redefined
"F821", # undefined-name, pylint undefined-variable, unexpected-keyword-arg
"F841", # unused-variable, pylint unused-variable
"ISC", # flake8-implicit-str-concat
"PIE790", # unnecessary-placeholder, pylint unnecessary-pass
"PLE0100", # yield-in-init, pylint init-is-generator
"PLE0101", # return-in-init, pylint return-in-init
Expand Down
Loading