Commit d589f8d9 authored by Ashwin Vishnu's avatar Ashwin Vishnu
Browse files

Skip fluidfft related tests.

Using extensive use of two new decorators:
- skip_if_no_fluidfft
- classproperty

Unit tests imports were made more modular. Tests which fail when fluidfft is
not installed are skipped.
parent be09672c0c6c
Pipeline #10372 passed with stage
in 16 minutes and 55 seconds
......@@ -4,9 +4,10 @@ import numpy as np
from fluidsim.base.solvers.pseudo_spect import SimulBasePseudoSpectral
from fluidsim.util.testing import TestSimul
from fluidsim.util.testing import TestSimul, skip_if_no_fluidfft
@skip_if_no_fluidfft()
class TestPreprocessPS(TestSimul):
Simul = SimulBasePseudoSpectral
......
......@@ -10,7 +10,6 @@ import fluiddyn.util.mpi as mpi
# to get fld.show
import fluiddyn.output
from fluidsim.base.solvers.pseudo_spect import SimulBasePseudoSpectral
from fluidsim import (
modif_resolution_from_dir,
load_params_simul,
......@@ -21,12 +20,16 @@ from fluidsim.util import times_start_end_from_path
from fluidsim.base.params import load_info_solver
from fluidsim.util.testing import TestSimul
from fluidsim.util.testing import TestSimul, classproperty, skip_if_no_fluidfft
@skip_if_no_fluidfft()
class TestBaseSolverPS(TestSimul):
@classproperty
def Simul(cls):
from fluidsim.base.solvers.pseudo_spect import SimulBasePseudoSpectral
Simul = SimulBasePseudoSpectral
return SimulBasePseudoSpectral
@classmethod
def setUpClass(cls):
......
import unittest
from fluidsim.base.params import merge_params
from fluidsim.base.solvers.base import SimulBase
from fluidsim.base.solvers.pseudo_spect import SimulBasePseudoSpectral as Simul
from fluidsim.util.testing import TestCase
......@@ -12,6 +10,9 @@ class TestParameters(TestCase):
def test_merge(self):
"""Test merging parameters."""
from fluidsim.base.solvers.base import SimulBase
from fluidsim.solvers.ad1d.solver import Simul
params1 = SimulBase.create_default_params()
params2 = Simul.create_default_params()
merge_params(params1, params2)
......
......@@ -5,17 +5,11 @@ from copy import deepcopy
import fluiddyn.util.mpi as mpi
from fluidsim.util.testing import TestCase
try:
from fluidsim.operators.operators2d import OperatorsPseudoSpectral2D
except ValueError:
NO_PYTHRAN = True
else:
NO_PYTHRAN = False
from fluidsim.util.testing import TestCase, skip_if_no_fluidfft
def create_oper(type_fft=None, coef_dealiasing=2.0 / 3, **kwargs):
from fluidsim.operators.operators2d import OperatorsPseudoSpectral2D
params = OperatorsPseudoSpectral2D._create_default_params()
......@@ -60,9 +54,7 @@ def compute_increments_dim1_old(var, irx):
return inc_var
@unittest.skipIf(
NO_PYTHRAN, "Pythran extension fluidsim.operators.util2d_pythran unavailable"
)
@skip_if_no_fluidfft()
@unittest.skipIf(sys.platform.startswith("win"), "Untested on Windows")
class TestOperators(TestCase):
@classmethod
......@@ -119,6 +111,7 @@ class TestOperators(TestCase):
assert_increments_equal(irx)
@skip_if_no_fluidfft()
class TestOperatorOnlyCoarse(TestCase):
@classmethod
def setUpClass(cls):
......@@ -139,6 +132,7 @@ class TestOperatorOnlyCoarse(TestCase):
self.assertNotEqual(oper.ny, self.nh)
@skip_if_no_fluidfft()
class TestOperatorsDealiasing(TestCase):
@classmethod
def setUpClass(cls):
......@@ -157,10 +151,16 @@ class TestOperatorsDealiasing(TestCase):
self.assertEqual(sum_var, sum_var_dealiased)
@skip_if_no_fluidfft()
class TestCoarse(unittest.TestCase):
Oper = OperatorsPseudoSpectral2D
nb_dim = 2
@property
def Oper(self):
from fluidsim.operators.operators2d import OperatorsPseudoSpectral2D
return OperatorsPseudoSpectral2D
def test_coarse(self):
params = self.Oper._create_default_params()
......@@ -190,6 +190,7 @@ class TestCoarse(unittest.TestCase):
field_coarse_fft = oper_coarse.fft(field_coarse)
if self.nb_dim == 2:
nkyc, nkxc = oper_coarse_shapeK_loc
# zeros because of conditions in put_coarse_array_in_array_fft
field_coarse_fft[nkyc // 2, :] = 0
......
import unittest
from fluidsim.operators.operators3d import OperatorsPseudoSpectral3D
from .test_operators2d import TestCoarse as _TestCoarse
class TestCoarse(_TestCoarse):
Oper = OperatorsPseudoSpectral3D
nb_dim = 3
@property
def Oper(self):
from fluidsim.operators.operators3d import OperatorsPseudoSpectral3D
return OperatorsPseudoSpectral3D
del _TestCoarse
......
from .solver import Simul
from ..test_solver import TestSolverAD1D as Base
from fluidsim.solvers.ad1d.test_solver import TestSolverAD1D as Base
class TestSolverAD1DPseudoSpectral(Base):
......
......@@ -7,12 +7,16 @@ import fluidsim as fls
import fluiddyn.util.mpi as mpi
from fluidsim.solvers.ns2d.solver import Simul
from fluidsim.util.testing import TestSimul
from fluidsim.util.testing import TestSimul, classproperty, skip_if_no_fluidfft
@skip_if_no_fluidfft()
class TestSimulBase(TestSimul):
Simul = Simul
@classproperty
def Simul(cls):
from fluidsim.solvers.ns2d.solver import Simul
return Simul
@classmethod
def init_params(cls):
......
......@@ -6,13 +6,15 @@ import fluiddyn.util.mpi as mpi
import fluidsim as fls
from ..test_solver import TestSimulBase as _Base
from .solver import Simul
from ..test_solver import TestSimulBase as _Base, classproperty
class TestSimulBase(_Base):
Simul = Simul
@classproperty
def Simul(self):
from .solver import Simul
return Simul
class TestOutput(TestSimulBase):
......
......@@ -15,7 +15,14 @@
"""
from fluidsim.base.output import OutputBasePseudoSpectral
from fluidsim.operators.operators3d import compute_energy_from_1field
try:
from fluidsim.operators.operators3d import compute_energy_from_1field
except ImportError:
from fluidsim import _is_testing
if not _is_testing:
raise
class Output(OutputBasePseudoSpectral):
......
......@@ -14,12 +14,18 @@
"""
from fluidsim.operators.operators3d import (
compute_energy_from_1field,
compute_energy_from_1field_with_coef,
compute_energy_from_2fields,
compute_energy_from_3fields,
)
try:
from fluidsim.operators.operators3d import (
compute_energy_from_1field,
compute_energy_from_1field_with_coef,
compute_energy_from_2fields,
compute_energy_from_3fields,
)
except ImportError:
from fluidsim import _is_testing
if not _is_testing:
raise
from ...output import Output as OutputNS3D
......
......@@ -7,13 +7,15 @@ import fluiddyn.util.mpi as mpi
import fluidsim as fls
from ..test_solver import TestSimulBase as _Base
from .solver import Simul
from ..test_solver import TestSimulBase as _Base, classproperty
class TestSimulBase(_Base):
Simul = Simul
@classproperty
def Simul(cls):
from .solver import Simul
return Simul
class TestTendency(TestSimulBase):
......
......@@ -15,15 +15,19 @@ from fluidsim import (
load_state_phys_file,
load_for_restart,
)
from fluidsim.solvers.ns3d.solver import Simul
from fluidsim.base.output import run
from fluidsim.util.testing import TestSimul
from fluidsim.util.testing import TestSimul, skip_if_no_fluidfft, classproperty
@skip_if_no_fluidfft()
class TestSimulBase(TestSimul):
Simul = Simul
@classproperty
def Simul(cls):
from fluidsim.solvers.ns3d.solver import Simul
return Simul
@classmethod
def init_params(cls):
......
......@@ -4,17 +4,21 @@ import numpy as np
import fluiddyn.util.mpi as mpi
from fluidsim.solvers.plate2d.solver import Simul
from fluidsim.util.testing import TestSimul
from fluidsim.util.testing import TestSimul, skip_if_no_fluidfft, classproperty
@skip_if_no_fluidfft()
class TestSimulBase(TestSimul):
Simul = Simul
@classproperty
def Simul(cls):
from fluidsim.solvers.plate2d.solver import Simul
return Simul
@classmethod
def init_params(cls, Lh=2, nh=32):
cls.params = params = Simul.create_default_params()
cls.params = params = cls.Simul.create_default_params()
params.short_name_type_run = "test"
params.output.sub_directory = "unittests"
cls.nh = nh
......
import unittest
import fluiddyn.util.mpi as mpi
from fluidsim.util.testing import TestSimulConserve
from fluidsim.solvers.sw1l.exactlin.modified.solver import Simul
from fluidsim.util.testing import (
TestSimulConserve,
classproperty,
skip_if_no_fluidfft,
)
@skip_if_no_fluidfft()
class TestSimulSW1LExactlinModified(TestSimulConserve):
Simul = Simul
@classproperty
def Simul(cls):
from fluidsim.solvers.sw1l.exactlin.modified.solver import Simul
return Simul
@classmethod
def init_params(cls):
......
import unittest
import fluiddyn.util.mpi as mpi
from fluidsim.util.testing import TestSimulConserveOutput
from fluidsim.solvers.sw1l.exactlin.solver import Simul
from fluidsim.util.testing import (
TestSimulConserveOutput,
classproperty,
skip_if_no_fluidfft,
)
@skip_if_no_fluidfft()
class TestSimulSW1LExactlin(TestSimulConserveOutput):
Simul = Simul
zero = 1e-3
@classproperty
def Simul(cls):
from fluidsim.solvers.sw1l.exactlin.solver import Simul
return Simul
@classmethod
def init_params(cls):
super().init_params()
......
import unittest
import fluiddyn.util.mpi as mpi
from fluidsim.util.testing import TestSimulConserveOutput
from fluidsim.solvers.sw1l.modified.solver import Simul
from fluidsim.util.testing import (
TestSimulConserveOutput,
classproperty,
skip_if_no_fluidfft,
)
@skip_if_no_fluidfft()
class TestSimulSW1LModified(TestSimulConserveOutput):
Simul = Simul
zero = 1e-8
@classproperty
def Simul(cls):
from fluidsim.solvers.sw1l.modified.solver import Simul
return Simul
@classmethod
def init_params(cls):
super().init_params()
......@@ -35,7 +45,7 @@ class TestSimulSW1LModified(TestSimulConserveOutput):
"""Test spect_energy_budg loading and plotting.
.. TODO::
Errors
* if periods_save = 0.25.
......
......@@ -2,14 +2,23 @@ import unittest
from numpy.testing import assert_array_almost_equal
import matplotlib.pyplot as plt
import fluiddyn.util.mpi as mpi
from fluidsim.util.testing import TestSimulConserve
from fluidsim.solvers.sw1l.onlywaves.solver import Simul
from fluidsim.util.testing import (
TestSimulConserve,
skip_if_no_fluidfft,
classproperty,
)
@skip_if_no_fluidfft()
class TestSimulSW1LWaves(TestSimulConserve):
Simul = Simul
zero = 1e-6
@classproperty
def Simul(cls):
from fluidsim.solvers.sw1l.onlywaves.solver import Simul
return Simul
@classmethod
def init_params(cls):
super().init_params()
......
......@@ -5,9 +5,7 @@ import sys
import fluiddyn.util.mpi as mpi
from fluiddyn.util.paramcontainer import ParamContainer
from fluidsim.util.testing import TestCase, stdout_redirected
from fluidsim.solvers.sw1l.operators import OperatorsPseudoSpectralSW1L
from fluidsim.util.testing import TestCase, stdout_redirected, skip_if_no_fluidfft
def create_oper(type_fft=None, coef_dealiasing=2.0 / 3):
......@@ -19,6 +17,8 @@ def create_oper(type_fft=None, coef_dealiasing=2.0 / 3):
params._set_attrib("c2", 100)
params._set_attrib("kd2", 0)
from fluidsim.solvers.sw1l.operators import OperatorsPseudoSpectralSW1L
OperatorsPseudoSpectralSW1L._complete_params_with_default(params)
if mpi.nb_proc == 1:
......@@ -42,6 +42,7 @@ def create_oper(type_fft=None, coef_dealiasing=2.0 / 3):
return oper
@skip_if_no_fluidfft()
@unittest.skipIf(sys.platform.startswith("win"), "Untested on Windows")
class TestOperators(TestCase):
@classmethod
......
import unittest
from numpy.testing import assert_array_almost_equal
import matplotlib.pyplot as plt
from numpy.testing import assert_array_almost_equal
import fluiddyn.util.mpi as mpi
from fluidsim.util.testing import TestSimulConserveOutput
from fluidsim.solvers.sw1l.solver import Simul
from fluidsim.util.testing import (
TestSimulConserveOutput,
classproperty,
skip_if_no_fluidfft,
)
@skip_if_no_fluidfft()
class TestSimulSW1L(TestSimulConserveOutput):
Simul = Simul
zero = 1e-5
@classproperty
def Simul(cls):
from fluidsim.solvers.sw1l.solver import Simul
return Simul
@classmethod
def init_params(cls):
super().init_params()
......
from fluidsim.util.testing import TestSimul
from fluidsim.solvers.waves2d.solver import Simul
from fluiddyn.util.compat import cached_property
from fluidsim.util.testing import TestSimul, skip_if_no_fluidfft, classproperty
@skip_if_no_fluidfft()
class TestSimulBase(TestSimul):
@classproperty
def Simul(cls):
from .solver import Simul
Simul = Simul
return Simul
@classmethod
def init_params(cls):
......@@ -31,7 +35,7 @@ class TestSimulBase(TestSimul):
class TestOutput(TestSimulBase):
@classmethod
def init_params(self):
def init_params(cls):
params = super().init_params()
params.init_fields.type = "noise"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment