diff --git a/docs/tutorials/07_examples_vehicle_routing.ipynb b/docs/tutorials/07_examples_vehicle_routing.ipynb index 2200155bc..aa348783a 100644 --- a/docs/tutorials/07_examples_vehicle_routing.ipynb +++ b/docs/tutorials/07_examples_vehicle_routing.ipynb @@ -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", diff --git a/docs/tutorials/08_cvar_optimization.ipynb b/docs/tutorials/08_cvar_optimization.ipynb index c6d23396b..9adc7566b 100644 --- a/docs/tutorials/08_cvar_optimization.ipynb +++ b/docs/tutorials/08_cvar_optimization.ipynb @@ -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", diff --git a/qiskit_optimization/algorithms/qrao/magic_rounding.py b/qiskit_optimization/algorithms/qrao/magic_rounding.py index b4f086d87..d4e962089 100644 --- a/qiskit_optimization/algorithms/qrao/magic_rounding.py +++ b/qiskit_optimization/algorithms/qrao/magic_rounding.py @@ -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 @@ -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() ] diff --git a/qiskit_optimization/algorithms/qrao/semideterministic_rounding.py b/qiskit_optimization/algorithms/qrao/semideterministic_rounding.py index 2b84e31fe..53e7e1af8 100644 --- a/qiskit_optimization/algorithms/qrao/semideterministic_rounding.py +++ b/qiskit_optimization/algorithms/qrao/semideterministic_rounding.py @@ -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 @@ -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 + ), ) ] diff --git a/qiskit_optimization/converters/integer_to_binary.py b/qiskit_optimization/converters/integer_to_binary.py index 961164e10..e36f3aa2a 100644 --- a/qiskit_optimization/converters/integer_to_binary.py +++ b/qiskit_optimization/converters/integer_to_binary.py @@ -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 @@ -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: @@ -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) ) diff --git a/requirements-dev.txt b/requirements-dev.txt index 0aefb685d..fb91bae47 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -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 diff --git a/test/algorithms/qrao/test_magic_rounding.py b/test/algorithms/qrao/test_magic_rounding.py index 0b7db9975..15caae128 100644 --- a/test/algorithms/qrao/test_magic_rounding.py +++ b/test/algorithms/qrao/test_magic_rounding.py @@ -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 @@ -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 + ), )