Skip to content

Commit

Permalink
Uppercase COMPILED_AVAILABLE
Browse files Browse the repository at this point in the history
  • Loading branch information
relf committed Feb 21, 2024
1 parent 30f4732 commit 45a75c7
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 70 deletions.
6 changes: 3 additions & 3 deletions smt/applications/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
try:
from smt.surrogate_models import IDW, RBF, RMTC, RMTB

compiled_available = True
COMPILED_AVAILABLE = True
except ImportError:
compiled_available = False
COMPILED_AVAILABLE = False


class SurrogateBasedApplication:
if compiled_available:
if COMPILED_AVAILABLE:
_surrogate_type = {
"KRG": KRG,
"LS": LS,
Expand Down
6 changes: 3 additions & 3 deletions smt/examples/run_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
try:
from smt.surrogate_models import IDW, RBF, RMTC, RMTB

compiled_available = True
COMPILED_AVAILABLE = True
except ImportError:
compiled_available = False
COMPILED_AVAILABLE = False

try:
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -466,7 +466,7 @@

if plot_status:
plt.show()
if compiled_available:
if COMPILED_AVAILABLE:
########### The IDW model

t = IDW(print_prediction=False)
Expand Down
34 changes: 17 additions & 17 deletions smt/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
try:
from smt.surrogate_models import IDW, RBF, RMTC, RMTB

compiled_available = True
COMPILED_AVAILABLE = True
except ImportError:
compiled_available = False
COMPILED_AVAILABLE = False


print_output = False
Expand Down Expand Up @@ -86,7 +86,7 @@ def setUp(self):
sms["MGP"] = KPLSK(theta0=[1e-2] * ncomp, n_comp=ncomp)
sms["GEKPLS"] = GEKPLS(theta0=[1e-2] * 2, n_comp=2, delta_x=1e-1)
sms["GENN"] = genn()
if compiled_available:
if COMPILED_AVAILABLE:
sms["IDW"] = IDW()
sms["RBF"] = RBF()
sms["RMTC"] = RMTC()
Expand All @@ -102,7 +102,7 @@ def setUp(self):
t_errors["MGP"] = 1e0
t_errors["GEKPLS"] = 1.4
t_errors["GENN"] = 1.2
if compiled_available:
if COMPILED_AVAILABLE:
t_errors["IDW"] = 1e0
t_errors["RBF"] = 1e-2
t_errors["RMTC"] = 1e-1
Expand All @@ -118,7 +118,7 @@ def setUp(self):
e_errors["MGP"] = 2e-2
e_errors["GEKPLS"] = 2e-2
e_errors["GENN"] = 2e-2
if compiled_available:
if COMPILED_AVAILABLE:
e_errors["IDW"] = 1e0
e_errors["RBF"] = 1e0
e_errors["RMTC"] = 2e-1
Expand Down Expand Up @@ -228,19 +228,19 @@ def test_exp_GEKPLS_TNC(self):
def test_exp_GENN(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_exp_IDW(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_exp_RBF(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_exp_RMTC(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_exp_RMTB(self):
self.run_test()

Expand Down Expand Up @@ -284,19 +284,19 @@ def test_tanh_GEKPLS_TNC(self):
def test_tanh_GENN(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_tanh_IDW(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_tanh_RBF(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_tanh_RMTC(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_tanh_RMTB(self):
self.run_test()

Expand Down Expand Up @@ -340,19 +340,19 @@ def test_cos_GEKPLS_TNC(self):
def test_cos_GENN(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_cos_IDW(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_cos_RBF(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_cos_RMTC(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_cos_RMTB(self):
self.run_test()

Expand Down
12 changes: 6 additions & 6 deletions smt/tests/test_derivs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
try:
from smt.surrogate_models import IDW, RBF, RMTC, RMTB

compiled_available = True
COMPILED_AVAILABLE = True
except ImportError:
compiled_available = False
COMPILED_AVAILABLE = False


print_output = False
Expand All @@ -41,7 +41,7 @@ def setUp(self):
problems["sphere"] = Sphere(ndim=ndim)

sms = OrderedDict()
if compiled_available:
if COMPILED_AVAILABLE:
sms["RBF"] = RBF()
sms["RMTC"] = RMTC()
sms["RMTB"] = RMTB()
Expand Down Expand Up @@ -106,15 +106,15 @@ def run_test(self):
# --------------------------------------------------------------------
# Function: sphere

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_sphere_RBF(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_sphere_RMTC(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_sphere_RMTB(self):
self.run_test()

Expand Down
18 changes: 9 additions & 9 deletions smt/tests/test_extrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
try:
from smt.surrogate_models import IDW, RBF, RMTC, RMTB

compiled_available = True
COMPILED_AVAILABLE = True
except ImportError:
compiled_available = False
COMPILED_AVAILABLE = False


print_output = False
Expand All @@ -38,7 +38,7 @@ def setUp(self):
problems["sphere"] = Sphere(ndim=ndim)

sms = OrderedDict()
if compiled_available:
if COMPILED_AVAILABLE:
sms["RMTC"] = RMTC(num_elements=6, extrapolate=True)
sms["RMTB"] = RMTB(order=4, num_ctrl_pts=10, extrapolate=True)

Expand Down Expand Up @@ -79,31 +79,31 @@ def run_test(self, sname, extrap_train=False, extrap_predict=False):
if extrap_predict:
sm.predict_values(x)

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_RMTC(self):
self.run_test("RMTC", False, False)

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_RMTC_train(self):
with self.assertRaises(Exception) as context:
self.run_test("RMTC", True, False)
self.assertEqual(str(context.exception), "Training points above max for 0")

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_RMTC_predict(self):
self.run_test("RMTC", False, True)

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_RMTB(self):
self.run_test("RMTB", False, False)

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_RMTB_train(self):
with self.assertRaises(Exception) as context:
self.run_test("RMTB", True, False)
self.assertEqual(str(context.exception), "Training points above max for 0")

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_RMTB_predict(self):
self.run_test("RMTB", False, True)

Expand Down
22 changes: 11 additions & 11 deletions smt/tests/test_high_dim.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
try:
from smt.surrogate_models import IDW, RBF, RMTC, RMTB

compiled_available = True
COMPILED_AVAILABLE = True
except ImportError:
compiled_available = False
COMPILED_AVAILABLE = False


print_output = False
Expand All @@ -48,7 +48,7 @@ def setUp(self):
sms["KRG"] = KRG(theta0=[4e-1] * ndim)
sms["KPLS"] = KPLS()

if compiled_available:
if COMPILED_AVAILABLE:
sms["IDW"] = IDW()
sms["RBF"] = RBF()

Expand Down Expand Up @@ -129,11 +129,11 @@ def test_sphere_KRG(self):
def test_sphere_KPLS(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_sphere_IDW(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_sphere_RBF(self):
self.run_test()

Expand All @@ -153,11 +153,11 @@ def test_exp_KRG(self):
def test_exp_KPLS(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_exp_IDW(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_exp_RBF(self):
self.run_test()

Expand All @@ -177,11 +177,11 @@ def test_tanh_KRG(self):
def test_tanh_KPLS(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_tanh_IDW(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_tanh_RBF(self):
self.run_test()

Expand All @@ -201,11 +201,11 @@ def test_cos_KRG(self):
def test_cos_KPLS(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_cos_IDW(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_cos_RBF(self):
self.run_test()

Expand Down
15 changes: 7 additions & 8 deletions smt/tests/test_output_derivs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
from smt.sampling_methods import FullFactorial
from smt.utils.sm_test_case import SMTestCase
from smt.utils.silence import Silence
from smt.utils.misc import compute_rms_error

try:
from smt.surrogate_models import IDW, RBF, RMTC, RMTB

compiled_available = True
COMPILED_AVAILABLE = True
except ImportError:
compiled_available = False
COMPILED_AVAILABLE = False


print_output = False
Expand All @@ -37,7 +36,7 @@ def setUp(self):
self.problem = Sphere(ndim=ndim)

self.sms = sms = OrderedDict()
if compiled_available:
if COMPILED_AVAILABLE:
sms["IDW"] = IDW()
sms["RBF"] = RBF()
sms["RMTB"] = RMTB(
Expand Down Expand Up @@ -104,19 +103,19 @@ def run_test(self):

self.assert_error(jac_fd, jac_an, rtol=5e-2)

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_IDW(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_RBF(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_RMTB(self):
self.run_test()

@unittest.skipIf(not compiled_available, "Compiled Fortran libraries not available")
@unittest.skipIf(not COMPILED_AVAILABLE, "Compiled Fortran libraries not available")
def test_RMTC(self):
self.run_test()

Expand Down
Loading

0 comments on commit 45a75c7

Please sign in to comment.