From 7554c15e0fde351164808fe957c9972f9909e11e Mon Sep 17 00:00:00 2001 From: Apostolos Chalkis Date: Wed, 23 Oct 2024 18:14:31 +0300 Subject: [PATCH] disable pylint too-many-positional-arguments error for the lines it pops up --- .../algorithms/admm_optimizer.py | 8 ++--- .../algorithms/cobyla_optimizer.py | 4 +-- .../goemans_williamson_optimizer.py | 4 +-- .../algorithms/grover_optimizer.py | 8 ++--- .../algorithms/minimum_eigen_optimizer.py | 4 +-- .../algorithms/optimization_algorithm.py | 4 +-- .../recursive_minimum_eigen_optimizer.py | 8 ++--- .../algorithms/slsqp_optimizer.py | 8 ++--- .../algorithms/warm_start_qaoa_optimizer.py | 4 +-- .../applications/vehicle_routing.py | 4 +-- .../minimum_eigensolvers/sampling_vqe.py | 4 +-- qiskit_optimization/optimizers/cobyla.py | 4 +-- qiskit_optimization/optimizers/nelder_mead.py | 4 +-- qiskit_optimization/optimizers/spsa.py | 16 +++------- .../problems/linear_constraint.py | 4 +-- .../problems/quadratic_constraint.py | 4 +-- .../problems/quadratic_objective.py | 4 +-- .../problems/quadratic_program.py | 32 +++++-------------- qiskit_optimization/problems/variable.py | 4 +-- .../translators/prettyprint.py | 4 +-- test/optimizers/test_spsa.py | 4 +-- 21 files changed, 35 insertions(+), 105 deletions(-) diff --git a/qiskit_optimization/algorithms/admm_optimizer.py b/qiskit_optimization/algorithms/admm_optimizer.py index 8b6230ab..0def1c9b 100644 --- a/qiskit_optimization/algorithms/admm_optimizer.py +++ b/qiskit_optimization/algorithms/admm_optimizer.py @@ -42,9 +42,7 @@ class ADMMParameters: """Defines a set of parameters for ADMM optimizer.""" - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def __init__( # pylint: disable=all + def __init__( # pylint: disable=too-many-positional-arguments self, rho_initial: float = 10000, factor_c: float = 100000, @@ -177,9 +175,7 @@ def __init__(self, op: QuadraticProgram, rho_initial: float) -> None: class ADMMOptimizationResult(OptimizationResult): """ADMMOptimization Result.""" - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def __init__( # pylint: disable=all + def __init__( # pylint: disable=too-many-positional-arguments self, x: np.ndarray, fval: float, diff --git a/qiskit_optimization/algorithms/cobyla_optimizer.py b/qiskit_optimization/algorithms/cobyla_optimizer.py index fae108e1..553014bb 100644 --- a/qiskit_optimization/algorithms/cobyla_optimizer.py +++ b/qiskit_optimization/algorithms/cobyla_optimizer.py @@ -43,9 +43,7 @@ class CobylaOptimizer(MultiStartOptimizer): >>> result = optimizer.solve(problem) """ - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def __init__( # pylint: disable=all + def __init__( # pylint: disable=too-many-positional-arguments self, rhobeg: float = 1.0, rhoend: float = 1e-4, diff --git a/qiskit_optimization/algorithms/goemans_williamson_optimizer.py b/qiskit_optimization/algorithms/goemans_williamson_optimizer.py index 44d37e26..bf015944 100644 --- a/qiskit_optimization/algorithms/goemans_williamson_optimizer.py +++ b/qiskit_optimization/algorithms/goemans_williamson_optimizer.py @@ -39,9 +39,7 @@ class GoemansWilliamsonOptimizationResult(OptimizationResult): values of just one solution. Explore ``samples`` for all possible solutions. """ - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def __init__( # pylint: disable=all + def __init__( # pylint: disable=too-many-positional-arguments self, x: Optional[Union[List[float], np.ndarray]], fval: float, diff --git a/qiskit_optimization/algorithms/grover_optimizer.py b/qiskit_optimization/algorithms/grover_optimizer.py index d489b9e1..548ef5da 100644 --- a/qiskit_optimization/algorithms/grover_optimizer.py +++ b/qiskit_optimization/algorithms/grover_optimizer.py @@ -41,9 +41,7 @@ class GroverOptimizer(OptimizationAlgorithm): """Uses Grover Adaptive Search (GAS) to find the minimum of a QUBO function.""" - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def __init__( # pylint: disable=all + def __init__( # pylint: disable=too-many-positional-arguments self, num_value_qubits: int, num_iterations: int = 3, @@ -327,9 +325,7 @@ def _bin_to_int(v: str, num_value_bits: int) -> int: class GroverOptimizationResult(OptimizationResult): """A result object for Grover Optimization methods.""" - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def __init__( # pylint: disable=all + def __init__( # pylint: disable=too-many-positional-arguments self, x: Union[List[float], np.ndarray], fval: float, diff --git a/qiskit_optimization/algorithms/minimum_eigen_optimizer.py b/qiskit_optimization/algorithms/minimum_eigen_optimizer.py index a0f510a2..67d72d0b 100644 --- a/qiskit_optimization/algorithms/minimum_eigen_optimizer.py +++ b/qiskit_optimization/algorithms/minimum_eigen_optimizer.py @@ -39,9 +39,7 @@ class MinimumEigenOptimizationResult(OptimizationResult): """Minimum Eigen Optimizer Result.""" - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def __init__( # pylint: disable=all + def __init__( # pylint: disable=too-many-positional-arguments self, x: Optional[Union[List[float], np.ndarray]], fval: Optional[float], diff --git a/qiskit_optimization/algorithms/optimization_algorithm.py b/qiskit_optimization/algorithms/optimization_algorithm.py index ab4f492f..fa21bbc9 100644 --- a/qiskit_optimization/algorithms/optimization_algorithm.py +++ b/qiskit_optimization/algorithms/optimization_algorithm.py @@ -97,9 +97,7 @@ class OptimizationResult: should maintain the order when generating a new ``OptimizationResult`` object. """ - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def __init__( # pylint: disable=all + def __init__( # pylint: disable=too-many-positional-arguments self, x: Union[List[float], np.ndarray] | None, fval: float | None, diff --git a/qiskit_optimization/algorithms/recursive_minimum_eigen_optimizer.py b/qiskit_optimization/algorithms/recursive_minimum_eigen_optimizer.py index d1ea6380..add88c0a 100644 --- a/qiskit_optimization/algorithms/recursive_minimum_eigen_optimizer.py +++ b/qiskit_optimization/algorithms/recursive_minimum_eigen_optimizer.py @@ -52,9 +52,7 @@ class IntermediateResult(Enum): class RecursiveMinimumEigenOptimizationResult(OptimizationResult): """Recursive Eigen Optimizer Result.""" - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def __init__( # pylint: disable=all + def __init__( # pylint: disable=too-many-positional-arguments self, x: Union[List[float], np.ndarray], fval: float, @@ -139,9 +137,7 @@ class RecursiveMinimumEigenOptimizer(OptimizationAlgorithm): from Symmetry Protection. `arXiv:1910.08980 `_ """ - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def __init__( # pylint: disable=all + def __init__( # pylint: disable=too-many-positional-arguments self, optimizer: OptimizationAlgorithm, min_num_vars: int = 1, diff --git a/qiskit_optimization/algorithms/slsqp_optimizer.py b/qiskit_optimization/algorithms/slsqp_optimizer.py index 6dec0cf6..47ebb126 100644 --- a/qiskit_optimization/algorithms/slsqp_optimizer.py +++ b/qiskit_optimization/algorithms/slsqp_optimizer.py @@ -30,9 +30,7 @@ class SlsqpOptimizationResult(OptimizationResult): SLSQP optimization result, defines additional properties that may be returned by the optimizer. """ - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def __init__( # pylint: disable=all + def __init__( # pylint: disable=too-many-positional-arguments self, x: Union[List[float], np.ndarray], fval: float, @@ -105,10 +103,8 @@ 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__( # pylint: disable=all + def __init__( # pylint: disable=too-many-positional-arguments self, iter: int = 100, acc: float = 1.0e-6, diff --git a/qiskit_optimization/algorithms/warm_start_qaoa_optimizer.py b/qiskit_optimization/algorithms/warm_start_qaoa_optimizer.py index e1e30f7d..b57cc710 100644 --- a/qiskit_optimization/algorithms/warm_start_qaoa_optimizer.py +++ b/qiskit_optimization/algorithms/warm_start_qaoa_optimizer.py @@ -198,9 +198,7 @@ class WarmStartQAOAOptimizer(MinimumEigenOptimizer): """ - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def __init__( # pylint: disable=all + def __init__( # pylint: disable=too-many-positional-arguments self, pre_solver: OptimizationAlgorithm, relax_for_pre_solver: bool, diff --git a/qiskit_optimization/applications/vehicle_routing.py b/qiskit_optimization/applications/vehicle_routing.py index ef376a3e..86d7b87a 100644 --- a/qiskit_optimization/applications/vehicle_routing.py +++ b/qiskit_optimization/applications/vehicle_routing.py @@ -215,11 +215,9 @@ 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( # pylint: disable=all + def create_random_instance( # pylint: disable=too-many-positional-arguments n: int, low: int = 0, high: int = 100, diff --git a/qiskit_optimization/minimum_eigensolvers/sampling_vqe.py b/qiskit_optimization/minimum_eigensolvers/sampling_vqe.py index dee381f2..fec4b513 100644 --- a/qiskit_optimization/minimum_eigensolvers/sampling_vqe.py +++ b/qiskit_optimization/minimum_eigensolvers/sampling_vqe.py @@ -343,9 +343,7 @@ def evaluate_energy(parameters: np.ndarray) -> np.ndarray | float: return evaluate_energy - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def _build_sampling_vqe_result( # pylint: disable=all + def _build_sampling_vqe_result( # pylint: disable=too-many-positional-arguments self, ansatz: QuantumCircuit, optimizer_result: OptimizerResult, diff --git a/qiskit_optimization/optimizers/cobyla.py b/qiskit_optimization/optimizers/cobyla.py index db9380f9..fe4e4a57 100644 --- a/qiskit_optimization/optimizers/cobyla.py +++ b/qiskit_optimization/optimizers/cobyla.py @@ -31,10 +31,8 @@ class COBYLA(SciPyOptimizer): _OPTIONS = ["maxiter", "disp", "rhobeg"] - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI # pylint: disable=unused-argument - def __init__( # pylint: disable=all + def __init__( # pylint: disable=too-many-positional-arguments self, maxiter: int = 1000, disp: bool = False, diff --git a/qiskit_optimization/optimizers/nelder_mead.py b/qiskit_optimization/optimizers/nelder_mead.py index 89a39302..12b3bb19 100644 --- a/qiskit_optimization/optimizers/nelder_mead.py +++ b/qiskit_optimization/optimizers/nelder_mead.py @@ -40,10 +40,8 @@ class NELDER_MEAD(SciPyOptimizer): # pylint: disable=invalid-name _OPTIONS = ["maxiter", "maxfev", "disp", "xatol", "adaptive"] - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI # pylint: disable=unused-argument - def __init__( # pylint: disable=all + def __init__( # pylint: disable=too-many-positional-arguments self, maxiter: int | None = None, maxfev: int = 1000, diff --git a/qiskit_optimization/optimizers/spsa.py b/qiskit_optimization/optimizers/spsa.py index 1289d24e..e9ccdde5 100644 --- a/qiskit_optimization/optimizers/spsa.py +++ b/qiskit_optimization/optimizers/spsa.py @@ -161,9 +161,7 @@ def __call__(self, nfev, parameters, value, stepsize, accepted) -> bool: """ - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def __init__( # pylint: disable=all + def __init__( # pylint: disable=too-many-positional-arguments self, maxiter: int = 100, blocking: bool = False, @@ -282,10 +280,8 @@ def __init__( # pylint: disable=all self._nfev: int | None = None # the number of function evaluations self._smoothed_hessian: np.ndarray | None = None # smoothed average of the Hessians - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI @staticmethod - def calibrate( # pylint: disable=all + def calibrate( # pylint: disable=too-many-positional-arguments loss: Callable[[np.ndarray], float], initial_point: np.ndarray, c: float = 0.2, @@ -417,9 +413,7 @@ def settings(self) -> dict[str, Any]: "termination_checker": self.termination_checker, } - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def _point_sample(self, loss, x, eps, delta1, delta2): # pylint: disable=all + def _point_sample(self, loss, x, eps, delta1, delta2): # pylint: disable=too-many-positional-arguments """A single sample of the gradient at position ``x`` in direction ``delta``.""" # points to evaluate points = [x + eps * delta1, x - eps * delta1] @@ -484,9 +478,7 @@ def _point_estimate(self, loss, x, eps, num_samples): hessian_estimate / num_samples, ) - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def _compute_update(self, loss, x, k, eps, lse_solver): # pylint: disable=all + def _compute_update(self, loss, x, k, eps, lse_solver): # pylint: disable=too-many-positional-arguments # compute the perturbations if isinstance(self.resamplings, dict): num_samples = self.resamplings.get(k, 1) diff --git a/qiskit_optimization/problems/linear_constraint.py b/qiskit_optimization/problems/linear_constraint.py index c7e7765c..e144289f 100644 --- a/qiskit_optimization/problems/linear_constraint.py +++ b/qiskit_optimization/problems/linear_constraint.py @@ -27,9 +27,7 @@ class LinearConstraint(Constraint): # Note: added, duplicating in effect that in Constraint, to avoid issues with Sphinx Sense = ConstraintSense - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def __init__( # pylint: disable=all + def __init__( # pylint: disable=too-many-positional-arguments self, quadratic_program: Any, name: str, diff --git a/qiskit_optimization/problems/quadratic_constraint.py b/qiskit_optimization/problems/quadratic_constraint.py index 623a47c4..ee044f36 100644 --- a/qiskit_optimization/problems/quadratic_constraint.py +++ b/qiskit_optimization/problems/quadratic_constraint.py @@ -28,9 +28,7 @@ class QuadraticConstraint(Constraint): # Note: added, duplicating in effect that in Constraint, to avoid issues with Sphinx Sense = ConstraintSense - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def __init__( # pylint: disable=all + def __init__( # pylint: disable=too-many-positional-arguments self, quadratic_program: Any, name: str, diff --git a/qiskit_optimization/problems/quadratic_objective.py b/qiskit_optimization/problems/quadratic_objective.py index 2104fe44..385735df 100644 --- a/qiskit_optimization/problems/quadratic_objective.py +++ b/qiskit_optimization/problems/quadratic_objective.py @@ -38,9 +38,7 @@ class QuadraticObjective(QuadraticProgramElement): Sense = ObjSense - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def __init__( # pylint: disable=all + def __init__( # pylint: disable=too-many-positional-arguments self, quadratic_program: Any, constant: float = 0.0, diff --git a/qiskit_optimization/problems/quadratic_program.py b/qiskit_optimization/problems/quadratic_program.py index 5d717561..7e5c19e6 100644 --- a/qiskit_optimization/problems/quadratic_program.py +++ b/qiskit_optimization/problems/quadratic_program.py @@ -185,9 +185,7 @@ def _add_variable( key_format = "" return self._add_variables(1, lowerbound, upperbound, vartype, name, key_format)[1][0] - # 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 + def _add_variables( # pylint: disable=too-many-positional-arguments self, keys: Union[int, Sequence], lowerbound: Union[float, int], @@ -241,9 +239,7 @@ def _find_name(name, key_format, k): variables.append(variable) return names, variables - # 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 + def _var_dict( # pylint: disable=too-many-positional-arguments self, keys: Union[int, Sequence], lowerbound: Union[float, int], @@ -281,9 +277,7 @@ def _var_dict( # pylint: disable=all zip(*self._add_variables(keys, lowerbound, upperbound, vartype, name, key_format)) ) - # 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 + def _var_list( # pylint: disable=too-many-positional-arguments self, keys: Union[int, Sequence], lowerbound: Union[float, int], @@ -339,9 +333,7 @@ def continuous_var( """ return self._add_variable(lowerbound, upperbound, Variable.Type.CONTINUOUS, name) - # 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 + def continuous_var_dict( # pylint: disable=too-many-positional-arguments self, keys: Union[int, Sequence], lowerbound: Union[float, int] = 0, @@ -380,9 +372,7 @@ def continuous_var_dict( # pylint: disable=all key_format=key_format, ) - # 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 + def continuous_var_list( # pylint: disable=too-many-positional-arguments self, keys: Union[int, Sequence], lowerbound: Union[float, int] = 0, @@ -516,9 +506,7 @@ def integer_var( """ return self._add_variable(lowerbound, upperbound, Variable.Type.INTEGER, name) - # 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 + def integer_var_dict( # pylint: disable=too-many-positional-arguments self, keys: Union[int, Sequence], lowerbound: Union[float, int] = 0, @@ -557,9 +545,7 @@ def integer_var_dict( # pylint: disable=all key_format=key_format, ) - # 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 + def integer_var_list( # pylint: disable=too-many-positional-arguments self, keys: Union[int, Sequence], lowerbound: Union[float, int] = 0, @@ -750,9 +736,7 @@ def quadratic_constraints_index(self) -> Dict[str, int]: """ return self._quadratic_constraints_index - # 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 + def quadratic_constraint( # pylint: disable=too-many-positional-arguments self, linear: Union[ndarray, spmatrix, List[float], Dict[Union[int, str], float]] = None, quadratic: Union[ diff --git a/qiskit_optimization/problems/variable.py b/qiskit_optimization/problems/variable.py index 20def0ee..06d8e048 100644 --- a/qiskit_optimization/problems/variable.py +++ b/qiskit_optimization/problems/variable.py @@ -33,9 +33,7 @@ class Variable(QuadraticProgramElement): Type = VarType - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def __init__( # pylint: disable=all + def __init__( # pylint: disable=too-many-positional-arguments self, quadratic_program: Any, name: str, diff --git a/qiskit_optimization/translators/prettyprint.py b/qiskit_optimization/translators/prettyprint.py index fa271a3a..2b4f97b6 100644 --- a/qiskit_optimization/translators/prettyprint.py +++ b/qiskit_optimization/translators/prettyprint.py @@ -117,9 +117,7 @@ def _concatenate_terms(terms: List[str], wrap: int, indent: int) -> str: return buf -# Delete all pylint checks because (too-many-positional-arguments) is unknown -# option value in some platforms in github CI -def expr2str( # pylint: disable=all +def expr2str( # pylint: disable=too-many-positional-arguments constant: float = 0.0, linear: Optional[LinearExpression] = None, quadratic: Optional[QuadraticExpression] = None, diff --git a/test/optimizers/test_spsa.py b/test/optimizers/test_spsa.py index 7424d7b1..f4b1f01e 100644 --- a/test/optimizers/test_spsa.py +++ b/test/optimizers/test_spsa.py @@ -129,9 +129,7 @@ class TerminationChecker: def __init__(self): self.values = [] - # Delete all pylint checks because (too-many-positional-arguments) is unknown - # option value in some platforms in github CI - def __call__( # pylint: disable=all + def __call__( # pylint: disable=too-many-positional-arguments self, nfev, point, fvalue, stepsize, accepted ) -> bool: self.values.append(fvalue)