Skip to content

Commit

Permalink
bump black version (#617) (#619)
Browse files Browse the repository at this point in the history
Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
(cherry picked from commit 5d20d2e)

Co-authored-by: Takashi Imamichi <31178928+t-imamichi@users.noreply.github.com>
  • Loading branch information
mergify[bot] and t-imamichi committed May 8, 2024
1 parent 30d0961 commit 23b565f
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 19 deletions.
4 changes: 1 addition & 3 deletions docs/tutorials/07_examples_vehicle_routing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,7 @@
" my_obj = list(instance.reshape(1, n**2)[0]) + [0.0 for x in range(0, n - 1)]\n",
" my_ub = [1 for x in range(0, n**2 + n - 1)]\n",
" my_lb = [0 for x in range(0, n**2)] + [0.1 for x in range(0, n - 1)]\n",
" my_ctype = \"\".join([\"I\" for x in range(0, n**2)]) + \"\".join(\n",
" [\"C\" for x in range(0, n - 1)]\n",
" )\n",
" my_ctype = \"\".join([\"I\" for x in range(0, n**2)]) + \"\".join([\"C\" for x in range(0, n - 1)])\n",
"\n",
" my_rhs = (\n",
" 2 * ([K] + [1 for x in range(0, n - 1)])\n",
Expand Down
1 change: 1 addition & 0 deletions docs/tutorials/08_cvar_optimization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"objectives = {alpha: [] for alpha in alphas} # set of tested objective functions w.r.t. alpha\n",
"results = {} # results of minimum eigensolver w.r.t alpha\n",
"\n",
"\n",
"# callback to store intermediate results\n",
"def callback(i, params, obj, stddev, alpha):\n",
" # we translate the objective from the internal Ising representation\n",
Expand Down
10 changes: 6 additions & 4 deletions qiskit_optimization/algorithms/qrao/magic_rounding.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of a Qiskit project.
#
# (C) Copyright IBM 2023.
# (C) Copyright IBM 2023, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand Down Expand Up @@ -446,9 +446,11 @@ def round(self, rounding_context: RoundingContext) -> RoundingResult:
[int(bit) for bit in soln]
),
probability=count / self._shots,
status=OptimizationResultStatus.SUCCESS
if rounding_context.encoding.problem.is_feasible([int(bit) for bit in soln])
else OptimizationResultStatus.INFEASIBLE,
status=(
OptimizationResultStatus.SUCCESS
if rounding_context.encoding.problem.is_feasible([int(bit) for bit in soln])
else OptimizationResultStatus.INFEASIBLE
),
)
for soln, count in soln_counts.items()
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of a Qiskit project.
#
# (C) Copyright IBM 2023.
# (C) Copyright IBM 2023, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand Down Expand Up @@ -68,9 +68,11 @@ def round(self, rounding_context: RoundingContext) -> RoundingResult:
x=np.asarray(rounded_vars),
fval=rounding_context.encoding.problem.objective.evaluate(rounded_vars),
probability=1.0,
status=OptimizationResultStatus.SUCCESS
if rounding_context.encoding.problem.is_feasible(rounded_vars)
else OptimizationResultStatus.INFEASIBLE,
status=(
OptimizationResultStatus.SUCCESS
if rounding_context.encoding.problem.is_feasible(rounded_vars)
else OptimizationResultStatus.INFEASIBLE
),
)
]

Expand Down
10 changes: 7 additions & 3 deletions qiskit_optimization/converters/integer_to_binary.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of a Qiskit project.
#
# (C) Copyright IBM 2020, 2023.
# (C) Copyright IBM 2020, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand Down Expand Up @@ -77,7 +77,7 @@ def convert(self, problem: QuadraticProgram) -> QuadraticProgram:
if x.vartype == Variable.Type.INTEGER:
new_vars = self._convert_var(x.name, x.lowerbound, x.upperbound)
self._conv[x] = new_vars
for (var_name, _) in new_vars:
for var_name, _ in new_vars:
self._dst.binary_var(var_name)
else:
if x.vartype == Variable.Type.CONTINUOUS:
Expand Down Expand Up @@ -164,7 +164,11 @@ def _substitute_int_var(self):
linear, linear_constant = self._convert_linear_coefficients_dict(
self._src.objective.linear.to_dict(use_name=True)
)
quadratic, q_linear, q_constant, = self._convert_quadratic_coefficients_dict(
(
quadratic,
q_linear,
q_constant,
) = self._convert_quadratic_coefficients_dict(
self._src.objective.quadratic.to_dict(use_name=True)
)

Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
coverage>=4.4.0
matplotlib>=2.1
black[jupyter]~=22.0
black[jupyter]~=24.1
pylint>=2.16.2
pylatexenc>=1.4
stestr>=4.1.0
Expand Down
10 changes: 6 additions & 4 deletions test/algorithms/qrao/test_magic_rounding.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of a Qiskit project.
#
# (C) Copyright IBM 2023.
# (C) Copyright IBM 2023, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand Down Expand Up @@ -328,9 +328,11 @@ def make_solution_sample(
x=x,
fval=problem.objective.evaluate(x),
probability=probability,
status=OptimizationResultStatus.SUCCESS
if problem.is_feasible(x)
else OptimizationResultStatus.INFEASIBLE,
status=(
OptimizationResultStatus.SUCCESS
if problem.is_feasible(x)
else OptimizationResultStatus.INFEASIBLE
),
)


Expand Down

0 comments on commit 23b565f

Please sign in to comment.