Skip to content

Commit

Permalink
Bump pylint from 3.2.7 to 3.3.0 (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored Oct 14, 2024
1 parent 13782f9 commit 0c2147f
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 44 deletions.
4 changes: 3 additions & 1 deletion libsigopt/compute/expected_improvement.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def __init__(
self,
predictor,
num_points_to_sample,
*,
points_being_sampled=None,
num_mc_iterations=DEFAULT_MC_ITERATIONS_TOTAL_QEI,
num_mc_iterations_per_loop=DEFAULT_MC_ITERATIONS_PER_LOOP_QEI,
Expand Down Expand Up @@ -332,14 +333,15 @@ def __init__(
predictor,
num_points_to_sample,
failure_model,
*,
points_being_sampled=None,
num_mc_iterations=DEFAULT_MC_ITERATIONS_TOTAL_QEIWF,
num_mc_iterations_per_loop=DEFAULT_MC_ITERATIONS_PER_LOOP_QEIWF,
):
super().__init__(
predictor,
num_points_to_sample,
points_being_sampled,
points_being_sampled=points_being_sampled,
num_mc_iterations=num_mc_iterations,
num_mc_iterations_per_loop=num_mc_iterations_per_loop,
)
Expand Down
1 change: 1 addition & 0 deletions libsigopt/compute/log_likelihood.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(
covariance,
historical_data,
mean_poly_indices=None,
*,
use_auto_noise=False,
log_domain=False,
scaling_factor=DEFAULT_LOG_LIKELIHOOD_SCALING_FACTOR,
Expand Down
4 changes: 4 additions & 0 deletions libsigopt/compute/misc/multimetric.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ def force_minimum_successful_points(optimizing_metric, points_sampled_values, po
return modified_points_sampled_failures


# pylint: disable=too-many-positional-arguments
def filter_convex_combination(
multimetric_info,
points_sampled_points,
Expand Down Expand Up @@ -567,3 +568,6 @@ def filter_multimetric_points_sampled_spe(
if multimetric_info.method != EPSILON_CONSTRAINT:
modified_points_sampled_values[points_sampled_failures] = modified_lie_value
return modified_points_sampled_points, modified_points_sampled_values


# pylint: enable=too-many-positional-arguments
1 change: 1 addition & 0 deletions libsigopt/compute/sigopt_parzen_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class SigOptParzenEstimator(ScipyOptimizable):

def __init__(
self,
*,
lower_covariance,
greater_covariance,
points_sampled_points,
Expand Down
16 changes: 13 additions & 3 deletions libsigopt/compute/vectorized_optimizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class VectorizedOptimizer(Optimizer):
optimizer_name: str
optimizer_parameters_type: type

def __init__(self, domain, acquisition_function, num_multistarts, optimizer_parameters, maxiter):
def __init__(self, domain, acquisition_function, num_multistarts, *, optimizer_parameters, maxiter):
"""
This is the base class for vectorized _maximization_.
"""
Expand Down Expand Up @@ -144,10 +144,17 @@ def __init__(
domain,
acquisition_function,
num_multistarts,
*,
optimizer_parameters=None,
maxiter=None,
):
super().__init__(domain, acquisition_function, num_multistarts, optimizer_parameters, maxiter)
super().__init__(
domain,
acquisition_function,
num_multistarts=num_multistarts,
optimizer_parameters=optimizer_parameters,
maxiter=maxiter,
)
self.strategy = self.optimizer_parameters.strategy
self.mutation = self.optimizer_parameters.mutation
self.crossover_probability = self.optimizer_parameters.crossover_probability
Expand Down Expand Up @@ -219,10 +226,13 @@ def __init__(
domain,
acquisition_function,
num_multistarts,
*,
optimizer_parameters=None,
maxiter=None,
):
super().__init__(domain, acquisition_function, num_multistarts, optimizer_parameters, maxiter)
super().__init__(
domain, acquisition_function, num_multistarts, optimizer_parameters=optimizer_parameters, maxiter=maxiter
)
self.learning_rate = self.optimizer_parameters.learning_rate
assert self.learning_rate >= 0
self.beta_1 = self.optimizer_parameters.beta_1
Expand Down
1 change: 1 addition & 0 deletions libsigopt/views/rest/gp_hyper_opt_multimetric.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def form_one_hot_hyperparameter_domain(
use_auto_noise,
discrete_lower_limit,
task_cost_populated,
*,
select_hyper_opt_in_log_domain=SELECT_HYPER_OPT_IN_LOG_DOMAIN,
):
ALPHA_LOWER_FACTOR = 0.001
Expand Down
1 change: 1 addition & 0 deletions libsigopt/views/rest/spe_next_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def draw_samples(
sigopt_parzen_estimator,
num_to_sample,
domain,
*,
num_multistarts=SPE_NUM_MULTISTARTS,
batch_size=SPE_BATCH_SIZE,
rejection_samples_limit=SPE_REJECTION_SAMPLES_LIMIT,
Expand Down
7 changes: 4 additions & 3 deletions libsigopt/views/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ def form_single_gaussian_process(
filtered_points_sampled_values,
filtered_points_sampled_value_vars,
filtered_scaled_lie_value,
*,
hyperparameter_dict,
):
one_hot_historical_data = HistoricalData(self.dim_with_task)
Expand Down Expand Up @@ -390,7 +391,7 @@ def form_gaussian_process_for_acquisition_function(self):
filtered_points_sampled_values[:, i],
filtered_points_sampled_value_vars[:, i],
filtered_scaled_lie_value[i],
self.params["model_info"].hyperparameters[metric_index],
hyperparameter_dict=self.params["model_info"].hyperparameters[metric_index],
)
gaussian_process_list.append(gp)
assert isinstance(self.multimetric_info.params, ConvexCombinationParams)
Expand All @@ -408,7 +409,7 @@ def form_gaussian_process_for_acquisition_function(self):
filtered_points_sampled_values,
filtered_points_sampled_value_vars,
filtered_scaled_lie_value,
self.params["model_info"].hyperparameters[metric_index],
hyperparameter_dict=self.params["model_info"].hyperparameters[metric_index],
)
return main_gaussian_process

Expand Down Expand Up @@ -436,7 +437,7 @@ def _form_gp_for_probabilistic_failures(self, relative_index, for_af_values=True
points_sampled_values[:, relative_index],
points_sampled_value_vars[:, relative_index],
scaled_lie_values[relative_index],
self.params["model_info"].hyperparameters[metric_indexes[relative_index]],
hyperparameter_dict=self.params["model_info"].hyperparameters[metric_indexes[relative_index]],
)

# TODO(RTL-85): I think a lot of this workflow can be cleanup up with find_epsilon_constraint_value better now
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ build==1.2.2.post1
flaky==3.8.1
mock==5.1.0
pre-commit==3.8.0
pylint==3.2.7
pylint==3.3.0
pytest==8.3.3
2 changes: 1 addition & 1 deletion test/testaux/numerical_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def assert_vector_within_relative_norm(value, truth, tol, norm=2):
assert err / mag < tol, f"error = {err} / magnitude = {mag} > tol = {tol}"

@staticmethod
def check_gradient_with_finite_difference(x, func, grad, fd_step, tol, use_complex=False):
def check_gradient_with_finite_difference(x, func, grad, fd_step, tol, *, use_complex=False):
"""
Approximate gradient using finite difference using either the centered method or complex step.
"""
Expand Down
71 changes: 36 additions & 35 deletions test/testcompute/spe_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright © 2022 Intel Corporation
#
# SPDX-License-Identifier: Apache License 2.0
# pylint: disable=too-many-positional-arguments
import random

import numpy
Expand Down Expand Up @@ -94,20 +95,20 @@ def test_default(self, form_multimetric_info, phase):
assert phase == EPSILON_CONSTRAINT
with pytest.raises(SPEInsufficientDataError):
SigOptParzenEstimator(
C0RadialMatern(hparams),
greater_covariance,
points_sampled.points,
points_sampled.values,
gamma,
lower_covariance=C0RadialMatern(hparams),
greater_covariance=greater_covariance,
points_sampled_points=points_sampled.points,
points_sampled_values=points_sampled.values,
gamma=gamma,
)
return

spe = SigOptParzenEstimator(
C0RadialMatern(hparams),
greater_covariance,
points_sampled.points,
points_sampled.values,
gamma,
lower_covariance=C0RadialMatern(hparams),
greater_covariance=greater_covariance,
points_sampled_points=points_sampled.points,
points_sampled_values=points_sampled.values,
gamma=gamma,
)
lpdf, gpdf, ei_vals = spe.evaluate_expected_improvement(points_to_sample)
assert all(lpdf) > 0 and all(gpdf) > 0 and all(ei_vals) > 0 and len(ei_vals) == len(points_to_sample)
Expand All @@ -116,11 +117,11 @@ def test_default(self, form_multimetric_info, phase):
spe.evaluate_grad_expected_improvement(points_to_sample)

spe = SigOptParzenEstimator(
C4RadialMatern(hparams),
greater_covariance,
points_sampled.points,
points_sampled.values,
gamma,
lower_covariance=C4RadialMatern(hparams),
greater_covariance=greater_covariance,
points_sampled_points=points_sampled.points,
points_sampled_values=points_sampled.values,
gamma=gamma,
)
assert spe.differentiable
ei_grad = spe.evaluate_grad_expected_improvement(points_to_sample)
Expand Down Expand Up @@ -152,11 +153,11 @@ def test_greater_lower_split(self, form_multimetric_info, phase):
# NOTE: max is used here since we don't apply MMI to values when creating SigOptParzenEstimator
numpy.place(values, failures, numpy.max(values))
spe = SigOptParzenEstimator(
C0RadialMatern(hparams),
greater_covariance,
points,
values,
gamma,
lower_covariance=C0RadialMatern(hparams),
greater_covariance=greater_covariance,
points_sampled_points=points,
points_sampled_values=values,
gamma=gamma,
)
sorted_indexed = numpy.argsort(values)
points_sorted = points[sorted_indexed, :]
Expand Down Expand Up @@ -193,11 +194,11 @@ def test_insufficient_data(self, form_multimetric_info, phase):
)
with pytest.raises(SPEInsufficientDataError):
SigOptParzenEstimator(
C0RadialMatern(hparams),
greater_covariance,
points_sampled.points,
points_sampled.values,
gamma,
lower_covariance=C0RadialMatern(hparams),
greater_covariance=greater_covariance,
points_sampled_points=points_sampled.points,
points_sampled_values=points_sampled.values,
gamma=gamma,
)

@pytest.mark.parametrize(
Expand All @@ -224,11 +225,11 @@ def test_insufficient_data_with_forget_factor(self, form_multimetric_info, phase
)
with pytest.raises(SPEInsufficientDataError):
SigOptParzenEstimator(
C0RadialMatern(hparams),
greater_covariance,
points_sampled.points,
points_sampled.values,
gamma,
lower_covariance=C0RadialMatern(hparams),
greater_covariance=greater_covariance,
points_sampled_points=points_sampled.points,
points_sampled_values=points_sampled.values,
gamma=gamma,
forget_factor=0.5,
)

Expand All @@ -237,11 +238,11 @@ def test_append_and_clear_lies(self):
points_sampled_points = domain.generate_quasi_random_points_in_domain(num_sampled)
points_sampled_values = numpy.random.rand(num_sampled)
spe = SigOptParzenEstimator(
C0RadialMatern(hparams),
greater_covariance,
points_sampled_points,
points_sampled_values,
gamma,
lower_covariance=C0RadialMatern(hparams),
greater_covariance=greater_covariance,
points_sampled_points=points_sampled_points,
points_sampled_values=points_sampled_values,
gamma=gamma,
)
assert spe.lower_points is not None
assert spe.greater_points is not None
Expand Down
1 change: 1 addition & 0 deletions test/testviews/rest/gp_ei_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright © 2022 Intel Corporation
#
# SPDX-License-Identifier: Apache License 2.0
# pylint: disable=too-many-positional-arguments
import pytest
from testviews.zigopt_input_utils import ZigoptSimulator

Expand Down
1 change: 1 addition & 0 deletions test/testviews/rest/gp_hyper_opt_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright © 2022 Intel Corporation
#
# SPDX-License-Identifier: Apache License 2.0
# pylint: disable=too-many-positional-arguments
from copy import deepcopy

import numpy
Expand Down
1 change: 1 addition & 0 deletions test/testviews/rest/gp_next_points_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright © 2022 Intel Corporation
#
# SPDX-License-Identifier: Apache License 2.0
# pylint: disable=too-many-positional-arguments
import numpy
import pytest
from flaky import flaky
Expand Down
1 change: 1 addition & 0 deletions test/testviews/rest/search_next_points_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright © 2022 Intel Corporation
#
# SPDX-License-Identifier: Apache License 2.0
# pylint: disable=too-many-positional-arguments
import numpy
import pytest
from mock import patch
Expand Down
1 change: 1 addition & 0 deletions test/testviews/rest/spe_next_points_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright © 2022 Intel Corporation
#
# SPDX-License-Identifier: Apache License 2.0
# pylint: disable=too-many-positional-arguments
import numpy
import pytest
from flaky import flaky
Expand Down
1 change: 1 addition & 0 deletions test/testviews/rest/spe_search_next_points_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright © 2022 Intel Corporation
#
# SPDX-License-Identifier: Apache License 2.0
# pylint: disable=too-many-positional-arguments
import numpy
import pytest
from testviews.zigopt_input_utils import ZigoptSimulator
Expand Down
1 change: 1 addition & 0 deletions test/testviews/view_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright © 2022 Intel Corporation
#
# SPDX-License-Identifier: Apache License 2.0
# pylint: disable=too-many-positional-arguments
import numpy
import pytest
from testviews.zigopt_input_utils import ZigoptSimulator, form_points_sampled
Expand Down
1 change: 1 addition & 0 deletions test/testviews/zigopt_input_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright © 2022 Intel Corporation
#
# SPDX-License-Identifier: Apache License 2.0
# pylint: disable=too-many-positional-arguments
import numpy

from libsigopt.aux.adapter_info_containers import DomainInfo, GPModelInfo, MetricsInfo, PointsContainer
Expand Down

0 comments on commit 0c2147f

Please sign in to comment.