From 9867c7fb2e2ecf245422ce4fd92dd75dd3f57088 Mon Sep 17 00:00:00 2001 From: relf Date: Tue, 5 Dec 2023 11:38:40 +0100 Subject: [PATCH] Fix test wrt platform --- smt/applications/tests/test_ego.py | 2 +- smt/tests/test_kpls_auto.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/smt/applications/tests/test_ego.py b/smt/applications/tests/test_ego.py index ef79cad82..1a61a8dfb 100644 --- a/smt/applications/tests/test_ego.py +++ b/smt/applications/tests/test_ego.py @@ -1005,7 +1005,7 @@ def f_obj(X): ) x_opt, y_opt, dnk, x_data, y_data = ego.optimize(fun=f_obj) if ds.HAS_CONFIG_SPACE: # results differs wrt config_space impl - if platform == "Linux": # results differs wrt platform + if platform.startsWith("linux"): # results differs wrt platform self.assertAlmostEqual(np.sum(y_data), 1.0355815090110578, delta=1e-12) self.assertAlmostEqual(np.sum(x_data), 38.23494224077761, delta=1e-12) else: diff --git a/smt/tests/test_kpls_auto.py b/smt/tests/test_kpls_auto.py index 00f689b03..04daa1c1a 100644 --- a/smt/tests/test_kpls_auto.py +++ b/smt/tests/test_kpls_auto.py @@ -7,6 +7,7 @@ import numpy as np import unittest import inspect +from sys import platform from collections import OrderedDict @@ -35,8 +36,6 @@ def setUp(self): problems["exp"] = TensorProduct(ndim=ndim, func="exp") problems["tanh"] = TensorProduct(ndim=ndim, func="tanh") problems["cos"] = TensorProduct(ndim=ndim, func="cos") - sms = OrderedDict() - sms["KPLS"] = KPLS(eval_n_comp=True) t_errors = {} e_errors = {} @@ -47,14 +46,16 @@ def setUp(self): n_comp_opt["Branin"] = 2 n_comp_opt["Rosenbrock"] = 1 n_comp_opt["sphere"] = 1 - n_comp_opt["exp"] = 3 + if platform.startsWith("linux"): # result depends on platform + n_comp_opt["exp"] = 2 + else: + n_comp_opt["exp"] = 3 n_comp_opt["tanh"] = 1 n_comp_opt["cos"] = 1 self.nt = nt self.ne = ne self.problems = problems - self.sms = sms self.t_errors = t_errors self.e_errors = e_errors self.n_comp_opt = n_comp_opt @@ -74,7 +75,7 @@ def run_test(self): xe = sampling(self.ne) ye = prob(xe) - sm0 = self.sms[sname] + sm0 = KPLS(eval_n_comp=True) sm = sm0.__class__() sm.options = sm0.options.clone()