From 32e0ebbbfec06aa89f8dd5e9290c49b2380489ec Mon Sep 17 00:00:00 2001 From: relf Date: Wed, 21 Feb 2024 16:50:02 +0100 Subject: [PATCH] Remove F401 --- pyproject.toml | 2 +- smt/applications/tests/test_ego.py | 8 +------- smt/applications/tests/test_mixed_integer.py | 17 +++-------------- smt/applications/tests/test_moe.py | 2 -- smt/applications/tests/test_vfm.py | 2 -- smt/applications/vfm.py | 2 -- .../b777_engine/tests/test_b777_engine.py | 8 +++++--- .../one_D_step/tests/test_one_D_step.py | 8 +++++--- .../rans_crm_wing/tests/test_rans_crm_wing.py | 8 +++++--- smt/examples/run_examples.py | 1 - smt/surrogate_models/tests/test_kpls.py | 3 +-- .../tests/test_krg_het_noise.py | 1 - smt/surrogate_models/tests/test_krg_outputs.py | 3 +-- smt/surrogate_models/tests/test_mgp.py | 3 +-- smt/surrogate_models/tests/test_qp.py | 7 ++----- .../tests/test_surrogate_model_examples.py | 3 +-- 16 files changed, 26 insertions(+), 52 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 89105b668..7846dc7ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,4 +2,4 @@ requires = ["setuptools", "wheel", "numpy", "Cython"] [tool.ruff.lint] -ignore = ["E402", "F401"] +ignore = ["E402"] diff --git a/smt/applications/tests/test_ego.py b/smt/applications/tests/test_ego.py index 0f5bc702a..b3278f008 100644 --- a/smt/applications/tests/test_ego.py +++ b/smt/applications/tests/test_ego.py @@ -354,8 +354,6 @@ def test_branin_2D_mixed_tunnel(self): @staticmethod def function_test_mixed_integer(X): - import numpy as np - # float x1 = X[:, 0] # XType.ENUM 1 @@ -1164,10 +1162,7 @@ def function_test_1d(x): def run_ego_mixed_integer_example(): import numpy as np from smt.applications import EGO - from smt.applications.mixed_integer import ( - MixedIntegerContext, - MixedIntegerSamplingMethod, - ) + from smt.applications.mixed_integer import MixedIntegerContext from smt.surrogate_models import MixIntKernelType from smt.utils.design_space import ( DesignSpace, @@ -1177,7 +1172,6 @@ def run_ego_mixed_integer_example(): ) import matplotlib.pyplot as plt from smt.surrogate_models import KRG - from smt.sampling_methods import LHS # Regarding the interface, the function to be optimized should handle # categorical values as index values in the enumeration type specification. diff --git a/smt/applications/tests/test_mixed_integer.py b/smt/applications/tests/test_mixed_integer.py index 971fa5b03..d1eb7dc00 100644 --- a/smt/applications/tests/test_mixed_integer.py +++ b/smt/applications/tests/test_mixed_integer.py @@ -530,10 +530,7 @@ def run_mixed_integer_qp_example(self): def run_mixed_integer_context_example(self): import matplotlib.pyplot as plt from smt.surrogate_models import KRG - from smt.applications.mixed_integer import ( - MixedIntegerContext, - MixedIntegerSamplingMethod, - ) + from smt.applications.mixed_integer import MixedIntegerContext from smt.utils.design_space import ( DesignSpace, FloatVariable, @@ -1850,7 +1847,6 @@ def run_mixed_gower_example(self): from smt.surrogate_models import KRG, MixIntKernelType from smt.applications.mixed_integer import ( MixedIntegerKrigingModel, - MixedIntegerSamplingMethod, ) from smt.utils.design_space import ( DesignSpace, @@ -1981,7 +1977,6 @@ def run_mixed_cs_example(self): from smt.surrogate_models import KRG, MixIntKernelType from smt.applications.mixed_integer import ( MixedIntegerKrigingModel, - MixedIntegerSamplingMethod, ) from smt.utils.design_space import ( DesignSpace, @@ -2110,10 +2105,7 @@ def run_mixed_homo_gaussian_example(self): import matplotlib.pyplot as plt from smt.surrogate_models import KRG, MixIntKernelType - from smt.applications.mixed_integer import ( - MixedIntegerKrigingModel, - MixedIntegerSamplingMethod, - ) + from smt.applications.mixed_integer import MixedIntegerKrigingModel from smt.utils.design_space import ( DesignSpace, CategoricalVariable, @@ -2241,10 +2233,7 @@ def run_mixed_homo_hyp_example(self): import matplotlib.pyplot as plt from smt.surrogate_models import KRG, MixIntKernelType - from smt.applications.mixed_integer import ( - MixedIntegerKrigingModel, - MixedIntegerSamplingMethod, - ) + from smt.applications.mixed_integer import MixedIntegerKrigingModel from smt.utils.design_space import ( DesignSpace, CategoricalVariable, diff --git a/smt/applications/tests/test_moe.py b/smt/applications/tests/test_moe.py index 4b8d2ce62..912cc1d94 100644 --- a/smt/applications/tests/test_moe.py +++ b/smt/applications/tests/test_moe.py @@ -126,7 +126,6 @@ def test_1d_50_var(self): if TestMOE.plot: import matplotlib.pyplot as plt - from mpl_toolkits.mplot3d import Axes3D y = moe.predict_values(xe) plt.figure(1) @@ -234,7 +233,6 @@ def test_norm1_2d_200(self): if TestMOE.plot: import matplotlib.pyplot as plt - from mpl_toolkits.mplot3d import Axes3D y = moe.predict_values(xe) plt.figure(1) diff --git a/smt/applications/tests/test_vfm.py b/smt/applications/tests/test_vfm.py index 863514150..d542211a4 100644 --- a/smt/applications/tests/test_vfm.py +++ b/smt/applications/tests/test_vfm.py @@ -15,7 +15,6 @@ NO_MATPLOTLIB = True import numpy as np -from scipy import linalg from smt.utils.sm_test_case import SMTestCase from smt.utils.silence import Silence @@ -27,7 +26,6 @@ from smt.examples.rans_crm_wing.rans_crm_wing import ( get_rans_crm_wing, - plot_rans_crm_wing, ) diff --git a/smt/applications/vfm.py b/smt/applications/vfm.py index bf810d71b..9c1ae9e9c 100644 --- a/smt/applications/vfm.py +++ b/smt/applications/vfm.py @@ -9,8 +9,6 @@ import numpy as np -from smt.utils.options_dictionary import OptionsDictionary -from types import FunctionType from smt.applications.application import SurrogateBasedApplication diff --git a/smt/examples/b777_engine/tests/test_b777_engine.py b/smt/examples/b777_engine/tests/test_b777_engine.py index 85a5f073b..1de8c8299 100644 --- a/smt/examples/b777_engine/tests/test_b777_engine.py +++ b/smt/examples/b777_engine/tests/test_b777_engine.py @@ -9,7 +9,7 @@ NO_MATPLOTLIB = True try: - from smt.surrogate_models import RMTB, RMTC + from smt.surrogate_models import RMTB, RMTC # noqa: F401 NO_COMPILED = True except ImportError: @@ -22,14 +22,16 @@ class Test(unittest.TestCase): "C compilation failed or matplotlib not installed", ) def test_rmtb(self): - from smt.examples.b777_engine import run_b777_engine_rmtb + # just check import + from smt.examples.b777_engine import run_b777_engine_rmtb # noqa: F401 @unittest.skipIf( NO_COMPILED or NO_MATPLOTLIB, "C compilation failed or matplotlib not installed", ) def test_rmtc(self): - from smt.examples.b777_engine import run_b777_engine_rmtc + # just check import + from smt.examples.b777_engine import run_b777_engine_rmtc # noqa: F401 if __name__ == "__main__": diff --git a/smt/examples/one_D_step/tests/test_one_D_step.py b/smt/examples/one_D_step/tests/test_one_D_step.py index 024162b26..aaebca6c4 100644 --- a/smt/examples/one_D_step/tests/test_one_D_step.py +++ b/smt/examples/one_D_step/tests/test_one_D_step.py @@ -9,7 +9,7 @@ NO_MATPLOTLIB = True try: - from smt.surrogate_models import RMTB, RMTC + from smt.surrogate_models import RMTB, RMTC # noqa: F401 NO_COMPILED = True except ImportError: @@ -22,11 +22,13 @@ class Test(unittest.TestCase): "C compilation failed or matplotlib not installed", ) def test_rmtb(self): - from smt.examples.one_D_step import run_one_D_step_rmtb + # just check import + from smt.examples.one_D_step import run_one_D_step_rmtb # noqa: F401 @unittest.skipIf( NO_COMPILED or NO_MATPLOTLIB, "C compilation failed or matplotlib not installed", ) def test_rmtc(self): - from smt.examples.one_D_step import run_one_D_step_rmtc + # just check import + from smt.examples.one_D_step import run_one_D_step_rmtc # noqa: F401 diff --git a/smt/examples/rans_crm_wing/tests/test_rans_crm_wing.py b/smt/examples/rans_crm_wing/tests/test_rans_crm_wing.py index fb3222260..ad5835afc 100644 --- a/smt/examples/rans_crm_wing/tests/test_rans_crm_wing.py +++ b/smt/examples/rans_crm_wing/tests/test_rans_crm_wing.py @@ -9,7 +9,7 @@ NO_MATPLOTLIB = True try: - from smt.surrogate_models import RMTB, RMTC + from smt.surrogate_models import RMTB, RMTC # noqa: F401 NO_COMPILED = True except ImportError: @@ -22,14 +22,16 @@ class Test(unittest.TestCase): "C compilation failed or matplotlib not installed", ) def test_rmtb(self): - from smt.examples.rans_crm_wing import run_rans_crm_wing_rmtb + # just check import + from smt.examples.rans_crm_wing import run_rans_crm_wing_rmtb # noqa: F401 @unittest.skipIf( NO_COMPILED or NO_MATPLOTLIB, "C compilation failedor matplotlib not installed", ) def test_rmtc(self): - from smt.examples.rans_crm_wing import run_rans_crm_wing_rmtc + # just check import + from smt.examples.rans_crm_wing import run_rans_crm_wing_rmtc # noqa: F401 if __name__ == "__main__": diff --git a/smt/examples/run_examples.py b/smt/examples/run_examples.py index f927bc434..629a54e3b 100644 --- a/smt/examples/run_examples.py +++ b/smt/examples/run_examples.py @@ -6,7 +6,6 @@ """ import numpy as np -from scipy import linalg from smt.utils.misc import compute_rms_error from smt.problems import Sphere, NdimRobotArm diff --git a/smt/surrogate_models/tests/test_kpls.py b/smt/surrogate_models/tests/test_kpls.py index be6b9ca72..1866a323e 100644 --- a/smt/surrogate_models/tests/test_kpls.py +++ b/smt/surrogate_models/tests/test_kpls.py @@ -7,8 +7,7 @@ import unittest import numpy as np from smt.surrogate_models import KPLS -from smt.problems import Sphere -from smt.sampling_methods import FullFactorial, LHS +from smt.sampling_methods import LHS class TestKPLS(unittest.TestCase): diff --git a/smt/surrogate_models/tests/test_krg_het_noise.py b/smt/surrogate_models/tests/test_krg_het_noise.py index 32f92b1e4..cf1190549 100644 --- a/smt/surrogate_models/tests/test_krg_het_noise.py +++ b/smt/surrogate_models/tests/test_krg_het_noise.py @@ -9,7 +9,6 @@ from smt.surrogate_models import KRG from smt.utils.sm_test_case import SMTestCase -from smt.utils.misc import compute_rms_error class Test(SMTestCase): diff --git a/smt/surrogate_models/tests/test_krg_outputs.py b/smt/surrogate_models/tests/test_krg_outputs.py index d004ae50f..2249bd8f2 100644 --- a/smt/surrogate_models/tests/test_krg_outputs.py +++ b/smt/surrogate_models/tests/test_krg_outputs.py @@ -7,8 +7,7 @@ import unittest import numpy as np from smt.surrogate_models import KRG -from smt.problems import Sphere -from smt.sampling_methods import FullFactorial, LHS +from smt.sampling_methods import LHS class TestKRG(unittest.TestCase): diff --git a/smt/surrogate_models/tests/test_mgp.py b/smt/surrogate_models/tests/test_mgp.py index c9b0911ef..5fe8ce5cf 100644 --- a/smt/surrogate_models/tests/test_mgp.py +++ b/smt/surrogate_models/tests/test_mgp.py @@ -7,8 +7,7 @@ import unittest import numpy as np from smt.surrogate_models import MGP -from smt.problems import Sphere -from smt.sampling_methods import FullFactorial, LHS +from smt.sampling_methods import LHS class TestMGP(unittest.TestCase): diff --git a/smt/surrogate_models/tests/test_qp.py b/smt/surrogate_models/tests/test_qp.py index e95e11a04..2b804602d 100644 --- a/smt/surrogate_models/tests/test_qp.py +++ b/smt/surrogate_models/tests/test_qp.py @@ -7,11 +7,8 @@ import unittest import numpy as np -from smt.surrogate_models import QP, KRG -from smt.examples.rans_crm_wing.rans_crm_wing import ( - get_rans_crm_wing, - plot_rans_crm_wing, -) +from smt.surrogate_models import QP +from smt.examples.rans_crm_wing.rans_crm_wing import get_rans_crm_wing class TestQP(unittest.TestCase): diff --git a/smt/surrogate_models/tests/test_surrogate_model_examples.py b/smt/surrogate_models/tests/test_surrogate_model_examples.py index c6c5d30d1..c311bba31 100644 --- a/smt/surrogate_models/tests/test_surrogate_model_examples.py +++ b/smt/surrogate_models/tests/test_surrogate_model_examples.py @@ -16,7 +16,7 @@ NO_MATPLOTLIB = True try: - from smt.surrogate_models import IDW, RBF, RMTB, RMTC + from smt.surrogate_models import IDW, RBF, RMTB, RMTC # noqa: F401 NO_COMPILED = False except ImportError: @@ -447,7 +447,6 @@ def test_kplsk(self): @unittest.skipIf(NO_MATPLOTLIB, "Matplotlib not installed") def test_gekpls(self): import numpy as np - from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt from smt.surrogate_models import GEKPLS, DesignSpace