Skip to content

Commit

Permalink
ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Saves committed Oct 17, 2024
1 parent 2f8639c commit 4b59342
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions smt/applications/tests/test_mixed_integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,9 +1040,9 @@ def test_hierarchical_design_space_example_all_categorical_decreed(self):
for mixint_kernel in [
MixIntKernelType.CONT_RELAX,
MixIntKernelType.GOWER,
# MixIntKernelType.COMPOUND_SYMMETRY,
# MixIntKernelType.EXP_HOMO_HSPHERE,
# MixIntKernelType.HOMO_HSPHERE,
# MixIntKernelType.COMPOUND_SYMMETRY,
# MixIntKernelType.EXP_HOMO_HSPHERE,
# MixIntKernelType.HOMO_HSPHERE,
]:
sm = MixedIntegerKrigingModel(
surrogate=KRG(
Expand All @@ -1059,7 +1059,7 @@ def test_hierarchical_design_space_example_all_categorical_decreed(self):
sm.train()
y_s = sm.predict_values(Xt)[:, 0]
_pred_RMSE = np.linalg.norm(y_s - Yt) / len(Yt)
self.assertLess(_pred_RMSE, 1e-4)
self.assertLess(_pred_RMSE, 1e-6)
y_sv = sm.predict_variances(Xt)[:, 0]
_var_RMSE = np.linalg.norm(y_sv) / len(Yt)
self.assertLess(_var_RMSE, 1e-6)
Expand Down
6 changes: 3 additions & 3 deletions smt/surrogate_models/krg_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ def _reduced_likelihood_function(self, theta):
X2 - self.X2_offset
) / self.X2_scale
dx, _ = cross_distances(self.X2_norma[str(self._lvl)])

try:
r = self._matrix_data_corr(
corr=self.options["corr"],
Expand All @@ -1001,7 +1001,7 @@ def _reduced_likelihood_function(self, theta):
cat_kernel=self.options["categorical_kernel"],
kplsk_second_loop=self.kplsk_second_loop,
).reshape(-1, 1)

if np.isnan(r).any():
return reduced_likelihood_function_value, par
except FloatingPointError:
Expand Down Expand Up @@ -1590,7 +1590,7 @@ def _predict_init(self, x, is_acting):
)
if np.any(self.design_space.is_conditionally_acting):
dx[:, np.logical_not(self.unfolded_cat)] = (
dnum / self.X2_scale[np.logical_not(self.unfolded_cat)]
dnum / self.X2_scale[np.logical_not(self.unfolded_cat)]
)
Lij, _ = cross_levels(
X=x, ij=ij, design_space=self.design_space, y=self.X_train
Expand Down
6 changes: 3 additions & 3 deletions smt/utils/kriging.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ def gower_componentwise_distances(
Z_num = Z[:, ~cat_features]
z_num_is_acting = z_is_acting[:, ~cat_features]
num_is_decreed = is_decreed[~cat_features]
X_num_out = Z_num[x_index,]
Y_num_out = Z_num[y_index,]
Z_num[x_index,]
Z_num[y_index,]
num_bounds = design_space.get_num_bounds()[~cat_features, :]
if num_bounds.shape[0] > 0:
Z_offset = num_bounds[:, 0]
Expand All @@ -327,7 +327,7 @@ def gower_componentwise_distances(
y,
hierarchical_kernel,
)
D_num_out= D_num*Z_scale
D_num_out = D_num * Z_scale
D = np.concatenate((D_cat, D_num), axis=1) * 0
D[:, np.logical_not(cat_features)] = D_num
D[:, cat_features] = D_cat
Expand Down

0 comments on commit 4b59342

Please sign in to comment.