Skip to content

Commit

Permalink
delete pylint disable=all from code
Browse files Browse the repository at this point in the history
  • Loading branch information
TolisChal committed Oct 23, 2024
1 parent 2ecaaae commit 6bddcc6
Show file tree
Hide file tree
Showing 21 changed files with 35 additions and 105 deletions.
8 changes: 2 additions & 6 deletions qiskit_optimization/algorithms/admm_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
self,
rho_initial: float = 10000,
factor_c: float = 100000,
Expand Down Expand Up @@ -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__(
self,
x: np.ndarray,
fval: float,
Expand Down
4 changes: 1 addition & 3 deletions qiskit_optimization/algorithms/cobyla_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
self,
rhobeg: float = 1.0,
rhoend: float = 1e-4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
self,
x: Optional[Union[List[float], np.ndarray]],
fval: float,
Expand Down
8 changes: 2 additions & 6 deletions qiskit_optimization/algorithms/grover_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
self,
num_value_qubits: int,
num_iterations: int = 3,
Expand Down Expand Up @@ -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__(
self,
x: Union[List[float], np.ndarray],
fval: float,
Expand Down
4 changes: 1 addition & 3 deletions qiskit_optimization/algorithms/minimum_eigen_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
self,
x: Optional[Union[List[float], np.ndarray]],
fval: Optional[float],
Expand Down
4 changes: 1 addition & 3 deletions qiskit_optimization/algorithms/optimization_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
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,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__(
self,
x: Union[List[float], np.ndarray],
fval: float,
Expand Down Expand Up @@ -139,9 +137,7 @@ class RecursiveMinimumEigenOptimizer(OptimizationAlgorithm):
from Symmetry Protection. `arXiv:1910.08980 <http://arxiv.org/abs/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__(
self,
optimizer: OptimizationAlgorithm,
min_num_vars: int = 1,
Expand Down
8 changes: 2 additions & 6 deletions qiskit_optimization/algorithms/slsqp_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
self,
x: Union[List[float], np.ndarray],
fval: float,
Expand Down Expand Up @@ -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__(
self,
iter: int = 100,
acc: float = 1.0e-6,
Expand Down
4 changes: 1 addition & 3 deletions qiskit_optimization/algorithms/warm_start_qaoa_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
self,
pre_solver: OptimizationAlgorithm,
relax_for_pre_solver: bool,
Expand Down
4 changes: 1 addition & 3 deletions qiskit_optimization/applications/vehicle_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
n: int,
low: int = 0,
high: int = 100,
Expand Down
4 changes: 1 addition & 3 deletions qiskit_optimization/minimum_eigensolvers/sampling_vqe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
self,
ansatz: QuantumCircuit,
optimizer_result: OptimizerResult,
Expand Down
4 changes: 1 addition & 3 deletions qiskit_optimization/optimizers/cobyla.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
self,
maxiter: int = 1000,
disp: bool = False,
Expand Down
4 changes: 1 addition & 3 deletions qiskit_optimization/optimizers/nelder_mead.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
self,
maxiter: int | None = None,
maxfev: int = 1000,
Expand Down
16 changes: 4 additions & 12 deletions qiskit_optimization/optimizers/spsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
self,
maxiter: int = 100,
blocking: bool = False,
Expand Down Expand Up @@ -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(
loss: Callable[[np.ndarray], float],
initial_point: np.ndarray,
c: float = 0.2,
Expand Down Expand Up @@ -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):
"""A single sample of the gradient at position ``x`` in direction ``delta``."""
# points to evaluate
points = [x + eps * delta1, x - eps * delta1]
Expand Down Expand Up @@ -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):
# compute the perturbations
if isinstance(self.resamplings, dict):
num_samples = self.resamplings.get(k, 1)
Expand Down
4 changes: 1 addition & 3 deletions qiskit_optimization/problems/linear_constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
self,
quadratic_program: Any,
name: str,
Expand Down
4 changes: 1 addition & 3 deletions qiskit_optimization/problems/quadratic_constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
self,
quadratic_program: Any,
name: str,
Expand Down
4 changes: 1 addition & 3 deletions qiskit_optimization/problems/quadratic_objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
self,
quadratic_program: Any,
constant: float = 0.0,
Expand Down
32 changes: 8 additions & 24 deletions qiskit_optimization/problems/quadratic_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
self,
keys: Union[int, Sequence],
lowerbound: Union[float, int],
Expand Down Expand Up @@ -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(
self,
keys: Union[int, Sequence],
lowerbound: Union[float, int],
Expand Down Expand Up @@ -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(
self,
keys: Union[int, Sequence],
lowerbound: Union[float, int],
Expand Down Expand Up @@ -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(
self,
keys: Union[int, Sequence],
lowerbound: Union[float, int] = 0,
Expand Down Expand Up @@ -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(
self,
keys: Union[int, Sequence],
lowerbound: Union[float, int] = 0,
Expand Down Expand Up @@ -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(
self,
keys: Union[int, Sequence],
lowerbound: Union[float, int] = 0,
Expand Down Expand Up @@ -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(
self,
keys: Union[int, Sequence],
lowerbound: Union[float, int] = 0,
Expand Down Expand Up @@ -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(
self,
linear: Union[ndarray, spmatrix, List[float], Dict[Union[int, str], float]] = None,
quadratic: Union[
Expand Down
4 changes: 1 addition & 3 deletions qiskit_optimization/problems/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
self,
quadratic_program: Any,
name: str,
Expand Down
4 changes: 1 addition & 3 deletions qiskit_optimization/translators/prettyprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
constant: float = 0.0,
linear: Optional[LinearExpression] = None,
quadratic: Optional[QuadraticExpression] = None,
Expand Down
4 changes: 1 addition & 3 deletions test/optimizers/test_spsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
self, nfev, point, fvalue, stepsize, accepted
) -> bool:
self.values.append(fvalue)
Expand Down

0 comments on commit 6bddcc6

Please sign in to comment.