Skip to content

Commit

Permalink
Improve pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
jungtaekkim committed May 20, 2024
1 parent 6a8dddb commit 5e2ebc5
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 87 deletions.
54 changes: 1 addition & 53 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -63,66 +63,14 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use "--disable=all --enable=classes
# --disable=W".
disable=old-raise-syntax,
import-star-module-level,
raw-checker-failed,
disable=raw-checker-failed,
bad-inline-option,
locally-disabled,
file-ignored,
suppressed-message,
useless-suppression,
deprecated-pragma,
use-symbolic-message-instead,
apply-builtin,
basestring-builtin,
buffer-builtin,
cmp-builtin,
coerce-builtin,
execfile-builtin,
file-builtin,
long-builtin,
raw_input-builtin,
reduce-builtin,
standarderror-builtin,
unicode-builtin,
xrange-builtin,
coerce-method,
no-absolute-import,
old-division,
dict-iter-method,
dict-view-method,
next-method-called,
metaclass-assignment,
indexing-exception,
reload-builtin,
nonzero-method,
cmp-method,
input-builtin,
round-builtin,
intern-builtin,
unichr-builtin,
map-builtin-not-iterating,
zip-builtin-not-iterating,
range-builtin-not-iterating,
filter-builtin-not-iterating,
using-cmp-argument,
exception-message-attribute,
invalid-str-codec,
sys-max-int,
bad-python3-import,
deprecated-string-function,
deprecated-str-translate-call,
deprecated-itertools-function,
deprecated-types-field,
next-method-defined,
dict-items-not-iterating,
dict-keys-not-iterating,
dict-values-not-iterating,
deprecated-operator-function,
deprecated-urllib-function,
xreadlines-attribute,
exception-escape,
comprehension-escape,
import-outside-toplevel,
bare-except

Expand Down
9 changes: 6 additions & 3 deletions bayeso/bo/bo_w_gp.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,12 @@ def optimize(
time_end_surrogate = time.time()

time_start_acq = time.time()
fun_negative_acquisition = lambda X_test: -1.0 * self.compute_acquisitions(
X_test, X_train, Y_train, cov_X_X, inv_cov_X_X, hyps
)

def fun_negative_acquisition(X_test):
return -1.0 * self.compute_acquisitions(
X_test, X_train, Y_train, cov_X_X, inv_cov_X_X, hyps
)

next_point, next_points = self._optimize(
fun_negative_acquisition,
str_sampling_method=str_sampling_method,
Expand Down
44 changes: 24 additions & 20 deletions bayeso/gp/gp_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,28 +91,32 @@ def get_optimized_kernel(
use_gradient = False

if str_modelselection_method == "ml":
neg_log_ml_ = lambda hyps: gp_likelihood.neg_log_ml(
X_train,
Y_train,
hyps,
str_cov,
prior_mu_train,
use_ard=use_ard,
fix_noise=fix_noise,
use_gradient=use_gradient,
debug=debug,
)
def neg_log_ml_(hyps):
return gp_likelihood.neg_log_ml(
X_train,
Y_train,
hyps,
str_cov,
prior_mu_train,
use_ard=use_ard,
fix_noise=fix_noise,
use_gradient=use_gradient,
debug=debug,
)

elif str_modelselection_method == "loocv":
# TODO: add use_ard.
neg_log_ml_ = lambda hyps: gp_likelihood.neg_log_pseudo_l_loocv(
X_train,
Y_train,
hyps,
str_cov,
prior_mu_train,
fix_noise=fix_noise,
debug=debug,
)
def neg_log_ml_(hyps):
return gp_likelihood.neg_log_pseudo_l_loocv(
X_train,
Y_train,
hyps,
str_cov,
prior_mu_train,
fix_noise=fix_noise,
debug=debug,
)

use_gradient = False
else: # pragma: no cover
raise ValueError(
Expand Down
23 changes: 12 additions & 11 deletions bayeso/tp/tp_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,18 @@ def get_optimized_kernel(
num_dim = X_train.shape[2]
use_gradient = False

neg_log_ml_ = lambda hyps: tp_likelihood.neg_log_ml(
X_train,
Y_train,
hyps,
str_cov,
prior_mu_train,
fix_noise=fix_noise,
use_gradient=use_gradient,
use_ard=use_ard,
debug=debug,
)
def neg_log_ml_(hyps):
return tp_likelihood.neg_log_ml(
X_train,
Y_train,
hyps,
str_cov,
prior_mu_train,
fix_noise=fix_noise,
use_gradient=use_gradient,
use_ard=use_ard,
debug=debug,
)

hyps_converted = utils_covariance.convert_hyps(
str_cov,
Expand Down

0 comments on commit 5e2ebc5

Please sign in to comment.