Skip to content

Commit 8394679

Browse files
Update black (backport #173) (#175)
Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 040e9af commit 8394679

File tree

10 files changed

+31
-28
lines changed

10 files changed

+31
-28
lines changed

qiskit_algorithms/amplitude_estimators/ae_utils.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This code is part of a Qiskit project.
22
#
3-
# (C) Copyright IBM 2018, 2023.
3+
# (C) Copyright IBM 2018, 2024.
44
#
55
# This code is licensed under the Apache License, Version 2.0. You may
66
# obtain a copy of this license in the LICENSE.txt file in the root directory
@@ -203,9 +203,11 @@ def pdf_a(x, p, m):
203203
# 0 and 1, respectively
204204
pr = np.array(
205205
[
206-
_pdf_a_single_angle(xi, p, m, _alpha) + _pdf_a_single_angle(xi, p, m, _beta)
207-
if (xi not in [0, 1])
208-
else _pdf_a_single_angle(xi, p, m, _alpha)
206+
(
207+
_pdf_a_single_angle(xi, p, m, _alpha) + _pdf_a_single_angle(xi, p, m, _beta)
208+
if (xi not in [0, 1])
209+
else _pdf_a_single_angle(xi, p, m, _alpha)
210+
)
209211
for xi in x
210212
]
211213
).flatten()

qiskit_algorithms/amplitude_estimators/estimation_problem.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This code is part of a Qiskit project.
22
#
3-
# (C) Copyright IBM 2020, 2023.
3+
# (C) Copyright IBM 2020, 2024.
44
#
55
# This code is licensed under the Apache License, Version 2.0. You may
66
# obtain a copy of this license in the LICENSE.txt file in the root directory
@@ -36,9 +36,9 @@ def __init__(
3636
state_preparation: QuantumCircuit,
3737
objective_qubits: int | list[int],
3838
grover_operator: QuantumCircuit | None = None,
39-
post_processing: Callable[[list[float]], list[float]]
40-
| Callable[[float], float]
41-
| None = None,
39+
post_processing: (
40+
Callable[[list[float]], list[float]] | Callable[[float], float] | None
41+
) = None,
4242
is_good_state: Callable[[str], bool] | None = None,
4343
) -> None:
4444
r"""

qiskit_algorithms/gradients/reverse/bind.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This code is part of a Qiskit project.
22
#
3-
# (C) Copyright IBM 2022, 2023.
3+
# (C) Copyright IBM 2022, 2024.
44
#
55
# This code is licensed under the Apache License, Version 2.0. You may
66
# obtain a copy of this license in the LICENSE.txt file in the root directory
@@ -17,6 +17,7 @@
1717

1818
from qiskit.circuit import QuantumCircuit, Parameter
1919

20+
2021
# pylint: disable=inconsistent-return-statements
2122
def bind(
2223
circuits: QuantumCircuit | Iterable[QuantumCircuit],

qiskit_algorithms/minimum_eigensolvers/sampling_vqe.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This code is part of a Qiskit project.
22
#
3-
# (C) Copyright IBM 2022, 2023.
3+
# (C) Copyright IBM 2022, 2024.
44
#
55
# This code is licensed under the Apache License, Version 2.0. You may
66
# obtain a copy of this license in the LICENSE.txt file in the root directory
@@ -266,9 +266,10 @@ def _get_evaluate_energy(
266266
operator: BaseOperator,
267267
ansatz: QuantumCircuit,
268268
return_best_measurement: bool = False,
269-
) -> Callable[[np.ndarray], np.ndarray | float] | tuple[
270-
Callable[[np.ndarray], np.ndarray | float], dict[str, Any]
271-
]:
269+
) -> (
270+
Callable[[np.ndarray], np.ndarray | float]
271+
| tuple[Callable[[np.ndarray], np.ndarray | float], dict[str, Any]]
272+
):
272273
"""Returns a function handle to evaluate the energy at given parameters.
273274
274275
This is the objective function to be passed to the optimizer that is used for evaluation.

qiskit_algorithms/optimizers/aqgd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def minimize(
325325
logger.info("Initial Params: %s", params)
326326
epoch = 0
327327
converged = False
328-
for (eta, mom_coeff) in zip(self._eta, self._momenta_coeff):
328+
for eta, mom_coeff in zip(self._eta, self._momenta_coeff):
329329
logger.info("Epoch: %4d | Stepsize: %6.4f | Momentum: %6.4f", epoch, eta, mom_coeff)
330330

331331
sum_max_iters = sum(self._maxiter[0 : epoch + 1])

qiskit_algorithms/optimizers/gradient_descent.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This code is part of a Qiskit project.
22
#
3-
# (C) Copyright IBM 2021, 2023.
3+
# (C) Copyright IBM 2021, 2024.
44
#
55
# This code is licensed under the Apache License, Version 2.0. You may
66
# obtain a copy of this license in the LICENSE.txt file in the root directory
@@ -177,10 +177,9 @@ def grad(x):
177177
def __init__(
178178
self,
179179
maxiter: int = 100,
180-
learning_rate: float
181-
| list[float]
182-
| np.ndarray
183-
| Callable[[], Generator[float, None, None]] = 0.01,
180+
learning_rate: (
181+
float | list[float] | np.ndarray | Callable[[], Generator[float, None, None]]
182+
) = 0.01,
184183
tol: float = 1e-7,
185184
callback: CALLBACK | None = None,
186185
perturbation: float | None = None,

qiskit_algorithms/optimizers/optimizer_utils/learning_rate.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This code is part of a Qiskit project.
22
#
3-
# (C) Copyright IBM 2021, 2023.
3+
# (C) Copyright IBM 2021, 2024.
44
#
55
# This code is licensed under the Apache License, Version 2.0. You may
66
# obtain a copy of this license in the LICENSE.txt file in the root directory
@@ -29,10 +29,9 @@ class LearningRate(Generator):
2929

3030
def __init__(
3131
self,
32-
learning_rate: float
33-
| list[float]
34-
| np.ndarray
35-
| Callable[[], Generator[float, None, None]],
32+
learning_rate: (
33+
float | list[float] | np.ndarray | Callable[[], Generator[float, None, None]]
34+
),
3635
):
3736
"""
3837
Args:

qiskit_algorithms/state_fidelities/base_state_fidelity.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This code is part of a Qiskit project.
22
#
3-
# (C) Copyright IBM 2022, 2023.
3+
# (C) Copyright IBM 2022, 2024.
44
#
55
# This code is licensed under the Apache License, Version 2.0. You may
66
# obtain a copy of this license in the LICENSE.txt file in the root directory
@@ -171,7 +171,7 @@ def _construct_circuits(
171171
)
172172

173173
circuits = []
174-
for (circuit_1, circuit_2) in zip(circuits_1, circuits_2):
174+
for circuit_1, circuit_2 in zip(circuits_1, circuits_2):
175175

176176
# Use the same key for circuits as qiskit.primitives use.
177177
circuit = self._circuit_cache.get((_circuit_key(circuit_1), _circuit_key(circuit_2)))
@@ -230,7 +230,7 @@ def _construct_value_list(
230230
elif len(values_1[0]) == 0:
231231
values = list(values_2)
232232
else:
233-
for (val_1, val_2) in zip(values_1, values_2):
233+
for val_1, val_2 in zip(values_1, values_2):
234234
# the `+` operation concatenates the lists
235235
# and then this new list gets appended to the values list
236236
values.append(val_1 + val_2)

requirements-dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
coverage>=4.4.0,<7.0
22
matplotlib>=3.3
33
jupyter
4-
black[jupyter]~=22.0
4+
black[jupyter]~=24.1
55
pylint>=2.15.0
66
stestr>=2.0.0
77
pylatexenc>=1.4

test/optimizers/test_optimizer_aqgd.py

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ def test_max_grouped_evals_parallelizable(self, max_grouped_evals):
114114

115115
def test_max_grouped_evals_non_parallelizable(self):
116116
"""Tests max_grouped_evals for an objective function that cannot be parallelized"""
117+
117118
# Define the objective function (toy example for functionality)
118119
def quadratic_objective(x: np.ndarray) -> float:
119120
# Check if only a single point as parameters is passed

0 commit comments

Comments
 (0)