Skip to content

Commit

Permalink
fix pylinter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
TolisChal committed Oct 12, 2024
1 parent c72f84c commit af6fa6e
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 23 deletions.
8 changes: 6 additions & 2 deletions qiskit_optimization/algorithms/admm_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
class ADMMParameters:
"""Defines a set of parameters for ADMM optimizer."""

def __init__(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def __init__( # pylint: disable=all
self,
rho_initial: float = 10000,
factor_c: float = 100000,
Expand Down Expand Up @@ -175,7 +177,9 @@ def __init__(self, op: QuadraticProgram, rho_initial: float) -> None:
class ADMMOptimizationResult(OptimizationResult):
"""ADMMOptimization Result."""

def __init__(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def __init__( # pylint: disable=all
self,
x: np.ndarray,
fval: float,
Expand Down
4 changes: 3 additions & 1 deletion qiskit_optimization/algorithms/cobyla_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ class CobylaOptimizer(MultiStartOptimizer):
>>> result = optimizer.solve(problem)
"""

def __init__(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def __init__( # pylint: disable=all
self,
rhobeg: float = 1.0,
rhoend: float = 1e-4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class GoemansWilliamsonOptimizationResult(OptimizationResult):
values of just one solution. Explore ``samples`` for all possible solutions.
"""

def __init__(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def __init__( # pylint: disable=all
self,
x: Optional[Union[List[float], np.ndarray]],
fval: float,
Expand Down
8 changes: 6 additions & 2 deletions qiskit_optimization/algorithms/grover_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
class GroverOptimizer(OptimizationAlgorithm):
"""Uses Grover Adaptive Search (GAS) to find the minimum of a QUBO function."""

def __init__(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def __init__( # pylint: disable=all
self,
num_value_qubits: int,
num_iterations: int = 3,
Expand Down Expand Up @@ -325,7 +327,9 @@ def _bin_to_int(v: str, num_value_bits: int) -> int:
class GroverOptimizationResult(OptimizationResult):
"""A result object for Grover Optimization methods."""

def __init__(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def __init__( # pylint: disable=all
self,
x: Union[List[float], np.ndarray],
fval: float,
Expand Down
4 changes: 3 additions & 1 deletion qiskit_optimization/algorithms/minimum_eigen_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
class MinimumEigenOptimizationResult(OptimizationResult):
"""Minimum Eigen Optimizer Result."""

def __init__(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def __init__( # pylint: disable=all
self,
x: Optional[Union[List[float], np.ndarray]],
fval: Optional[float],
Expand Down
4 changes: 3 additions & 1 deletion qiskit_optimization/algorithms/optimization_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ class OptimizationResult:
should maintain the order when generating a new ``OptimizationResult`` object.
"""

def __init__(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def __init__( # pylint: disable=all
self,
x: Union[List[float], np.ndarray] | None,
fval: float | None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ class IntermediateResult(Enum):
class RecursiveMinimumEigenOptimizationResult(OptimizationResult):
"""Recursive Eigen Optimizer Result."""

def __init__(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def __init__( # pylint: disable=all
self,
x: Union[List[float], np.ndarray],
fval: float,
Expand Down Expand Up @@ -137,7 +139,9 @@ class RecursiveMinimumEigenOptimizer(OptimizationAlgorithm):
from Symmetry Protection. `arXiv:1910.08980 <http://arxiv.org/abs/1910.08980>`_
"""

def __init__(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def __init__( # pylint: disable=all
self,
optimizer: OptimizationAlgorithm,
min_num_vars: int = 1,
Expand Down
8 changes: 6 additions & 2 deletions qiskit_optimization/algorithms/slsqp_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class SlsqpOptimizationResult(OptimizationResult):
SLSQP optimization result, defines additional properties that may be returned by the optimizer.
"""

def __init__(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def __init__( # pylint: disable=all
self,
x: Union[List[float], np.ndarray],
fval: float,
Expand Down Expand Up @@ -103,8 +105,10 @@ class SlsqpOptimizer(MultiStartOptimizer):
>>> result = optimizer.solve(problem)
"""

# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
# pylint: disable=redefined-builtin
def __init__(
def __init__( # pylint: disable=all
self,
iter: int = 100,
acc: float = 1.0e-6,
Expand Down
4 changes: 3 additions & 1 deletion qiskit_optimization/algorithms/warm_start_qaoa_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ class WarmStartQAOAOptimizer(MinimumEigenOptimizer):
"""

def __init__(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def __init__( # pylint: disable=all
self,
pre_solver: OptimizationAlgorithm,
relax_for_pre_solver: bool,
Expand Down
4 changes: 3 additions & 1 deletion qiskit_optimization/applications/vehicle_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,11 @@ def depot(self, depot: int) -> None:
"""
self._depot = depot

# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
@staticmethod
# pylint: disable=undefined-variable
def create_random_instance(
def create_random_instance( # pylint: disable=all
n: int,
low: int = 0,
high: int = 100,
Expand Down
32 changes: 24 additions & 8 deletions qiskit_optimization/problems/quadratic_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ def _add_variable(
key_format = ""
return self._add_variables(1, lowerbound, upperbound, vartype, name, key_format)[1][0]

def _add_variables(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def _add_variables( # pylint: disable=all
self,
keys: Union[int, Sequence],
lowerbound: Union[float, int],
Expand Down Expand Up @@ -239,7 +241,9 @@ def _find_name(name, key_format, k):
variables.append(variable)
return names, variables

def _var_dict(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def _var_dict( # pylint: disable=all
self,
keys: Union[int, Sequence],
lowerbound: Union[float, int],
Expand Down Expand Up @@ -277,7 +281,9 @@ def _var_dict(
zip(*self._add_variables(keys, lowerbound, upperbound, vartype, name, key_format))
)

def _var_list(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def _var_list( # pylint: disable=all
self,
keys: Union[int, Sequence],
lowerbound: Union[float, int],
Expand Down Expand Up @@ -333,7 +339,9 @@ def continuous_var(
"""
return self._add_variable(lowerbound, upperbound, Variable.Type.CONTINUOUS, name)

def continuous_var_dict(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def continuous_var_dict( # pylint: disable=all
self,
keys: Union[int, Sequence],
lowerbound: Union[float, int] = 0,
Expand Down Expand Up @@ -367,7 +375,9 @@ def continuous_var_dict(
keys, lowerbound, upperbound, Variable.Type.CONTINUOUS, name, key_format
)

def continuous_var_list(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def continuous_var_list( # pylint: disable=all
self,
keys: Union[int, Sequence],
lowerbound: Union[float, int] = 0,
Expand Down Expand Up @@ -494,7 +504,9 @@ def integer_var(
"""
return self._add_variable(lowerbound, upperbound, Variable.Type.INTEGER, name)

def integer_var_dict(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def integer_var_dict( # pylint: disable=all
self,
keys: Union[int, Sequence],
lowerbound: Union[float, int] = 0,
Expand Down Expand Up @@ -526,7 +538,9 @@ def integer_var_dict(
"""
return self._var_dict(keys, lowerbound, upperbound, Variable.Type.INTEGER, name, key_format)

def integer_var_list(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def integer_var_list( # pylint: disable=all
self,
keys: Union[int, Sequence],
lowerbound: Union[float, int] = 0,
Expand Down Expand Up @@ -717,7 +731,9 @@ def quadratic_constraints_index(self) -> Dict[str, int]:
"""
return self._quadratic_constraints_index

def quadratic_constraint(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def quadratic_constraint( # pylint: disable=all
self,
linear: Union[ndarray, spmatrix, List[float], Dict[Union[int, str], float]] = None,
quadratic: Union[
Expand Down
4 changes: 3 additions & 1 deletion qiskit_optimization/translators/prettyprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ def _concatenate_terms(terms: List[str], wrap: int, indent: int) -> str:
return buf


def expr2str(
# Delete all pylint checks because (too-many-positional-arguments) is unknown
# option value in some platforms in github CI
def expr2str( # pylint: disable=all
constant: float = 0.0,
linear: Optional[LinearExpression] = None,
quadratic: Optional[QuadraticExpression] = None,
Expand Down

0 comments on commit af6fa6e

Please sign in to comment.