diff --git a/.github/actions/compile/action.yml b/.github/actions/compile/action.yml index 46657900f..13c4986ab 100644 --- a/.github/actions/compile/action.yml +++ b/.github/actions/compile/action.yml @@ -17,3 +17,6 @@ runs: struphy compile -d -y && struphy compile -y --language ${{ matrix.compile-language }} ) + struphy compile --status + struphy --refresh-models + diff --git a/.github/actions/tests/unit-mpi/action.yml b/.github/actions/tests/unit-mpi/action.yml new file mode 100644 index 000000000..e03f490ef --- /dev/null +++ b/.github/actions/tests/unit-mpi/action.yml @@ -0,0 +1,10 @@ +name: "Run unit tests with MPI" + +runs: + using: composite + steps: + - name: Run unit tests with MPI + shell: bash + run: | + pip install mpi4py + struphy test unit --mpi 2 diff --git a/.github/actions/tests/unit/action.yml b/.github/actions/tests/unit/action.yml index 385d6f419..73450ab3b 100644 --- a/.github/actions/tests/unit/action.yml +++ b/.github/actions/tests/unit/action.yml @@ -3,19 +3,17 @@ name: "Run unit tests" runs: using: composite steps: - - name: Run unit tests with MPI - shell: bash - run: | - struphy compile --status - struphy --refresh-models - struphy test unit --mpi 2 - - name: Run unit tests + - name: Uninstall MPI shell: bash run: | - struphy compile --status - struphy --refresh-models pip show mpi4py pip uninstall -y mpi4py pip list + + - name: Run unit tests without MPI + shell: bash + env: + TESTMON_DATAFILE: ${{ github.workspace }}/.testmondata-${{ matrix.test-type }} + run: | struphy test unit diff --git a/.github/workflows/macos-latest.yml b/.github/workflows/macos-latest.yml index 2b5a1b0e5..e8afedbc7 100644 --- a/.github/workflows/macos-latest.yml +++ b/.github/workflows/macos-latest.yml @@ -9,9 +9,9 @@ # - main # - devel -# # concurrency: -# # group: ${{ github.ref }} -# # cancel-in-progress: true +# concurrency: +# group: ${{ github.workflow }}-${{ github.ref }} +# cancel-in-progress: true # jobs: # macos-latest-build: diff --git a/.github/workflows/static_analysis.yml b/.github/workflows/static_analysis.yml index 3022a70c2..e999f498d 100644 --- a/.github/workflows/static_analysis.yml +++ b/.github/workflows/static_analysis.yml @@ -10,9 +10,10 @@ on: - main - devel -# concurrency: -# group: ${{ github.ref }} -# cancel-in-progress: true +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + defaults: run: shell: bash diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index c27af6914..700984010 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -17,8 +17,8 @@ jobs: fail-fast: false matrix: python-version: ["3.12"] - compile-language: ["fortran", "c"] - test-type: ["unit", "model", "quickstart", "tutorials"] + compile-language: ["fortran"] #, "c"] + test-type: ["unit"] #, "model", "quickstart", "tutorials"] steps: # Checkout the repository @@ -43,7 +43,21 @@ jobs: key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} restore-keys: | ${{ runner.os }}-pip- + + - uses: actions/cache@v4 + with: + path: .testmondata-${{ matrix.test-type }} + key: testmon-${{ matrix.test-type }}-${{ github.sha }} + restore-keys: | + testmon-${{ matrix.test-type }}-${{ github.ref }}- + testmon-${{ matrix.test-type }}-${{ github.ref_name }}- + testmon-${{ matrix.test-type }}-refs/heads/devel- + testmon-${{ matrix.test-type }}-devel- + testmon-${{ matrix.test-type }}- + - name: Check .testmondata + run: ls -la testmon* || echo "No .testmondata" + # Install prereqs # I don't think it's possible to use a single action for this because # we can't use ${inputs.os} in an if statement, so we have to use two different actions. @@ -81,6 +95,10 @@ jobs: - name: Run unit tests if: matrix.test-type == 'unit' uses: ./.github/actions/tests/unit + + - name: Run unit tests with MPI + if: matrix.test-type == 'unit' + uses: ./.github/actions/tests/unit-mpi - name: Run model tests if: matrix.test-type == 'model' @@ -93,3 +111,10 @@ jobs: - name: Run tutorials if: matrix.test-type == 'tutorials' uses: ./.github/actions/tests/tutorials + + # Upload .testmondata as cache for later tests + - uses: actions/cache/save@v4 + if: always() + with: + path: .testmondata-${{ matrix.test-type }} + key: testmon-${{ matrix.test-type }}-${{ github.sha }} diff --git a/.github/workflows/ubuntu-latest.yml b/.github/workflows/ubuntu-latest.yml index e66aeb3b3..1ad7e188a 100644 --- a/.github/workflows/ubuntu-latest.yml +++ b/.github/workflows/ubuntu-latest.yml @@ -9,9 +9,9 @@ on: - main - devel -# concurrency: -# group: ${{ github.ref }} -# cancel-in-progress: true +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: ubuntu-latest-build: diff --git a/.gitignore b/.gitignore index e01ccf71d..1eb752517 100644 --- a/.gitignore +++ b/.gitignore @@ -88,6 +88,7 @@ code_analysis_report.html src/struphy/io/out/ src/struphy/state.yml src/struphy/io/inp/params_* +struphy_verification_tests/ # models list src/struphy/models/models_list diff --git a/pyproject.toml b/pyproject.toml index 9ee050079..1e9d81b4a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,6 +35,7 @@ dependencies = [ 'argcomplete', 'pytest', 'pytest-mpi', + 'pytest-testmon', 'line_profiler', ] @@ -133,6 +134,7 @@ kinetic-diagnostics = "struphy.diagnostics.console_diagn:main" struphy = [ "compile_struphy.mk", "psydac-2.5.0.dev0-py3-none-any.whl", + "conftest.py", ] [tool.autopep8] @@ -184,3 +186,5 @@ markers = [ "hybrid", "single", ] + + diff --git a/src/struphy/console/test.py b/src/struphy/console/test.py index ebcff34d4..553a616da 100644 --- a/src/struphy/console/test.py +++ b/src/struphy/console/test.py @@ -1,5 +1,42 @@ +import os +import pytest +import struphy from struphy.utils.utils import subp_run +LIBPATH = struphy.__path__[0] + +import pytest +from pathlib import Path + +def collect_changed_tests(test_path): + """Collect changed tests using pytest-testmon, returning full absolute nodeids.""" + + collected = [] + + class Collector: + def pytest_collection_modifyitems(self, session, config, items): + for item in items: + abs_path = Path(item.fspath).resolve() + # Keep the test name and parameters after '::' + node_suffix = item.nodeid.split("::", 1)[1] if "::" in item.nodeid else "" + if node_suffix: + full_nodeid = f"{abs_path}::{node_suffix}" + else: + full_nodeid = str(abs_path) + collected.append(full_nodeid) + # Stop after collection phase + raise pytest.UsageError("COLLECT_ONLY") + + args = ["--testmon", "--collect-only", "-q", str(test_path)] + print(args) + + try: + pytest.main(args, plugins=[Collector()]) + except pytest.UsageError: + print('exit') + pass # Expected exit after collection + + return collected def struphy_test( group: str, @@ -35,23 +72,34 @@ def struphy_test( """ if "unit" in group: + + tests = collect_changed_tests( + f"{LIBPATH}/tests/unit/bsplines/" + ) + + print(f"{tests = }") + + if len(tests) == 0: + print("No changed tests detected!") + return + if mpi > 1: cmd = [ "mpirun", "-n", str(mpi), "pytest", - "-k", - "not _models and not _tutorial and not pproc", + # "--testmon", "--with-mpi", ] else: cmd = [ "pytest", - "-k", - "not _models and not _tutorial and not pproc", + "--testmon", ] + cmd += tests + if with_desc: cmd += ["--with-desc"] if vrbose: @@ -59,6 +107,8 @@ def struphy_test( if show_plots: cmd += ["--show-plots"] + # Run in the current directory + cwd = os.getcwd() subp_run(cmd) elif group in {"models", "fluid", "kinetic", "hybrid", "toy"}: @@ -69,21 +119,21 @@ def struphy_test( "-n", str(mpi), "pytest", - "-k", - "_models", "-m", group, "-s", + # "--testmon", "--with-mpi", + f"{LIBPATH}/tests/models/", ] else: cmd = [ "pytest", - "-k", - "_models", "-m", group, "-s", + "--testmon", + f"{LIBPATH}/tests/models/", ] if vrbose: @@ -92,6 +142,9 @@ def struphy_test( cmd += ["--nclones", f"{nclones}"] if show_plots: cmd += ["--show-plots"] + + # Run in the current directory + cwd = os.getcwd() subp_run(cmd) elif "verification" in group: @@ -102,17 +155,17 @@ def struphy_test( "-n", str(mpi), "pytest", - "-k", - "_verif_", "-s", + # "--testmon", "--with-mpi", + f"{LIBPATH}/tests/verification/", ] else: cmd = [ "pytest", - "-k", - "_verif_", "-s", + "--testmon", + f"{LIBPATH}/models/tests/verification/", ] if vrbose: @@ -121,6 +174,9 @@ def struphy_test( cmd += ["--nclones", f"{nclones}"] if show_plots: cmd += ["--show-plots"] + + # Run in the current directory + cwd = os.getcwd() subp_run(cmd) else: @@ -130,11 +186,10 @@ def struphy_test( "-n", str(mpi), "pytest", - "-k", - "_models", "-m", "single", "-s", + # "--testmon", "--with-mpi", "--model-name", group, @@ -145,4 +200,7 @@ def struphy_test( cmd += ["--nclones", f"{nclones}"] if show_plots: cmd += ["--show-plots"] + + # Run in the current directory + cwd = os.getcwd() subp_run(cmd) diff --git a/src/struphy/feec/psydac_derham.py b/src/struphy/feec/psydac_derham.py index e5a8cde32..d4b305e93 100644 --- a/src/struphy/feec/psydac_derham.py +++ b/src/struphy/feec/psydac_derham.py @@ -103,6 +103,10 @@ def __init__( local_projectors: bool = False, domain: Domain = None, ): + + + + # number of elements, spline degrees and kind of splines in each direction (periodic vs. clamped) assert len(Nel) == 3 assert len(p) == 3 diff --git a/src/struphy/linear_algebra/saddle_point.py b/src/struphy/linear_algebra/saddle_point.py index 337664754..f793bdeba 100644 --- a/src/struphy/linear_algebra/saddle_point.py +++ b/src/struphy/linear_algebra/saddle_point.py @@ -7,7 +7,7 @@ from psydac.linalg.direct_solvers import SparseSolver from psydac.linalg.solvers import inverse -from struphy.linear_algebra.tests.test_saddlepoint_massmatrices import _plot_residual_norms +from struphy.tests.unit.linear_algebra.test_saddlepoint_massmatrices import _plot_residual_norms class SaddlePointSolver: diff --git a/src/struphy/models/tests/test_models.py b/src/struphy/tests/model/test_models.py similarity index 100% rename from src/struphy/models/tests/test_models.py rename to src/struphy/tests/model/test_models.py diff --git a/src/struphy/models/tests/test_xxpproc.py b/src/struphy/tests/model/test_xxpproc.py similarity index 100% rename from src/struphy/models/tests/test_xxpproc.py rename to src/struphy/tests/model/test_xxpproc.py diff --git a/src/struphy/bsplines/tests/__init__.py b/src/struphy/tests/unit/bsplines/__init__.py similarity index 100% rename from src/struphy/bsplines/tests/__init__.py rename to src/struphy/tests/unit/bsplines/__init__.py diff --git a/src/struphy/bsplines/tests/test_bsplines_kernels.py b/src/struphy/tests/unit/bsplines/test_bsplines_kernels.py similarity index 99% rename from src/struphy/bsplines/tests/test_bsplines_kernels.py rename to src/struphy/tests/unit/bsplines/test_bsplines_kernels.py index c1010dd08..55b5eeedd 100644 --- a/src/struphy/bsplines/tests/test_bsplines_kernels.py +++ b/src/struphy/tests/unit/bsplines/test_bsplines_kernels.py @@ -20,6 +20,9 @@ def test_bsplines_span_and_basis(Nel, p, spl_kind): from struphy.feec.psydac_derham import Derham from struphy.feec.utilities import create_equal_random_arrays as cera + + + comm = MPI.COMM_WORLD rank = comm.Get_rank() diff --git a/src/struphy/bsplines/tests/test_eval_spline_mpi.py b/src/struphy/tests/unit/bsplines/test_eval_spline_mpi.py similarity index 100% rename from src/struphy/bsplines/tests/test_eval_spline_mpi.py rename to src/struphy/tests/unit/bsplines/test_eval_spline_mpi.py diff --git a/src/struphy/console/tests/test_console.py b/src/struphy/tests/unit/console/test_console.py similarity index 100% rename from src/struphy/console/tests/test_console.py rename to src/struphy/tests/unit/console/test_console.py diff --git a/src/struphy/feec/tests/__init__.py b/src/struphy/tests/unit/feec/__init__.py similarity index 100% rename from src/struphy/feec/tests/__init__.py rename to src/struphy/tests/unit/feec/__init__.py diff --git a/src/struphy/feec/tests/test_basis_ops.py b/src/struphy/tests/unit/feec/test_basis_ops.py similarity index 100% rename from src/struphy/feec/tests/test_basis_ops.py rename to src/struphy/tests/unit/feec/test_basis_ops.py diff --git a/src/struphy/feec/tests/test_derham.py b/src/struphy/tests/unit/feec/test_derham.py similarity index 100% rename from src/struphy/feec/tests/test_derham.py rename to src/struphy/tests/unit/feec/test_derham.py diff --git a/src/struphy/feec/tests/test_eval_field.py b/src/struphy/tests/unit/feec/test_eval_field.py similarity index 100% rename from src/struphy/feec/tests/test_eval_field.py rename to src/struphy/tests/unit/feec/test_eval_field.py diff --git a/src/struphy/feec/tests/test_field_init.py b/src/struphy/tests/unit/feec/test_field_init.py similarity index 100% rename from src/struphy/feec/tests/test_field_init.py rename to src/struphy/tests/unit/feec/test_field_init.py diff --git a/src/struphy/feec/tests/test_l2_projectors.py b/src/struphy/tests/unit/feec/test_l2_projectors.py similarity index 100% rename from src/struphy/feec/tests/test_l2_projectors.py rename to src/struphy/tests/unit/feec/test_l2_projectors.py diff --git a/src/struphy/feec/tests/test_local_projectors.py b/src/struphy/tests/unit/feec/test_local_projectors.py similarity index 100% rename from src/struphy/feec/tests/test_local_projectors.py rename to src/struphy/tests/unit/feec/test_local_projectors.py diff --git a/src/struphy/feec/tests/test_lowdim_nel_is_1.py b/src/struphy/tests/unit/feec/test_lowdim_nel_is_1.py similarity index 100% rename from src/struphy/feec/tests/test_lowdim_nel_is_1.py rename to src/struphy/tests/unit/feec/test_lowdim_nel_is_1.py diff --git a/src/struphy/feec/tests/test_mass_matrices.py b/src/struphy/tests/unit/feec/test_mass_matrices.py similarity index 100% rename from src/struphy/feec/tests/test_mass_matrices.py rename to src/struphy/tests/unit/feec/test_mass_matrices.py diff --git a/src/struphy/feec/tests/test_toarray_struphy.py b/src/struphy/tests/unit/feec/test_toarray_struphy.py similarity index 100% rename from src/struphy/feec/tests/test_toarray_struphy.py rename to src/struphy/tests/unit/feec/test_toarray_struphy.py diff --git a/src/struphy/feec/tests/test_tosparse_struphy.py b/src/struphy/tests/unit/feec/test_tosparse_struphy.py similarity index 100% rename from src/struphy/feec/tests/test_tosparse_struphy.py rename to src/struphy/tests/unit/feec/test_tosparse_struphy.py diff --git a/src/struphy/feec/tests/xx_test_preconds.py b/src/struphy/tests/unit/feec/xx_test_preconds.py similarity index 100% rename from src/struphy/feec/tests/xx_test_preconds.py rename to src/struphy/tests/unit/feec/xx_test_preconds.py diff --git a/src/struphy/fields_background/tests/__init__.py b/src/struphy/tests/unit/fields_background/__init__.py similarity index 100% rename from src/struphy/fields_background/tests/__init__.py rename to src/struphy/tests/unit/fields_background/__init__.py diff --git a/src/struphy/fields_background/tests/test_desc_equil.py b/src/struphy/tests/unit/fields_background/test_desc_equil.py similarity index 100% rename from src/struphy/fields_background/tests/test_desc_equil.py rename to src/struphy/tests/unit/fields_background/test_desc_equil.py diff --git a/src/struphy/fields_background/tests/test_generic_equils.py b/src/struphy/tests/unit/fields_background/test_generic_equils.py similarity index 100% rename from src/struphy/fields_background/tests/test_generic_equils.py rename to src/struphy/tests/unit/fields_background/test_generic_equils.py diff --git a/src/struphy/fields_background/tests/test_mhd_equils.py b/src/struphy/tests/unit/fields_background/test_mhd_equils.py similarity index 100% rename from src/struphy/fields_background/tests/test_mhd_equils.py rename to src/struphy/tests/unit/fields_background/test_mhd_equils.py diff --git a/src/struphy/fields_background/tests/test_numerical_mhd_equil.py b/src/struphy/tests/unit/fields_background/test_numerical_mhd_equil.py similarity index 100% rename from src/struphy/fields_background/tests/test_numerical_mhd_equil.py rename to src/struphy/tests/unit/fields_background/test_numerical_mhd_equil.py diff --git a/src/struphy/geometry/tests/__init__.py b/src/struphy/tests/unit/geometry/__init__.py similarity index 100% rename from src/struphy/geometry/tests/__init__.py rename to src/struphy/tests/unit/geometry/__init__.py diff --git a/src/struphy/geometry/tests/test_domain.py b/src/struphy/tests/unit/geometry/test_domain.py similarity index 100% rename from src/struphy/geometry/tests/test_domain.py rename to src/struphy/tests/unit/geometry/test_domain.py diff --git a/src/struphy/initial/tests/__init__.py b/src/struphy/tests/unit/initial/__init__.py similarity index 100% rename from src/struphy/initial/tests/__init__.py rename to src/struphy/tests/unit/initial/__init__.py diff --git a/src/struphy/initial/tests/test_init_perturbations.py b/src/struphy/tests/unit/initial/test_init_perturbations.py similarity index 100% rename from src/struphy/initial/tests/test_init_perturbations.py rename to src/struphy/tests/unit/initial/test_init_perturbations.py diff --git a/src/struphy/kinetic_background/tests/__init__.py b/src/struphy/tests/unit/kinetic_background/__init__.py similarity index 100% rename from src/struphy/kinetic_background/tests/__init__.py rename to src/struphy/tests/unit/kinetic_background/__init__.py diff --git a/src/struphy/kinetic_background/tests/test_base.py b/src/struphy/tests/unit/kinetic_background/test_base.py similarity index 100% rename from src/struphy/kinetic_background/tests/test_base.py rename to src/struphy/tests/unit/kinetic_background/test_base.py diff --git a/src/struphy/kinetic_background/tests/test_maxwellians.py b/src/struphy/tests/unit/kinetic_background/test_maxwellians.py similarity index 100% rename from src/struphy/kinetic_background/tests/test_maxwellians.py rename to src/struphy/tests/unit/kinetic_background/test_maxwellians.py diff --git a/src/struphy/linear_algebra/tests/__init__.py b/src/struphy/tests/unit/linear_algebra/__init__.py similarity index 100% rename from src/struphy/linear_algebra/tests/__init__.py rename to src/struphy/tests/unit/linear_algebra/__init__.py diff --git a/src/struphy/linear_algebra/tests/test_saddle_point_propagator.py b/src/struphy/tests/unit/linear_algebra/test_saddle_point_propagator.py similarity index 100% rename from src/struphy/linear_algebra/tests/test_saddle_point_propagator.py rename to src/struphy/tests/unit/linear_algebra/test_saddle_point_propagator.py diff --git a/src/struphy/linear_algebra/tests/test_saddlepoint_massmatrices.py b/src/struphy/tests/unit/linear_algebra/test_saddlepoint_massmatrices.py similarity index 100% rename from src/struphy/linear_algebra/tests/test_saddlepoint_massmatrices.py rename to src/struphy/tests/unit/linear_algebra/test_saddlepoint_massmatrices.py diff --git a/src/struphy/linear_algebra/tests/test_stencil_dot_kernels.py b/src/struphy/tests/unit/linear_algebra/test_stencil_dot_kernels.py similarity index 100% rename from src/struphy/linear_algebra/tests/test_stencil_dot_kernels.py rename to src/struphy/tests/unit/linear_algebra/test_stencil_dot_kernels.py diff --git a/src/struphy/linear_algebra/tests/test_stencil_transpose_kernels.py b/src/struphy/tests/unit/linear_algebra/test_stencil_transpose_kernels.py similarity index 100% rename from src/struphy/linear_algebra/tests/test_stencil_transpose_kernels.py rename to src/struphy/tests/unit/linear_algebra/test_stencil_transpose_kernels.py diff --git a/src/struphy/ode/tests/__init__.py b/src/struphy/tests/unit/ode/__init__.py similarity index 100% rename from src/struphy/ode/tests/__init__.py rename to src/struphy/tests/unit/ode/__init__.py diff --git a/src/struphy/ode/tests/test_ode_feec.py b/src/struphy/tests/unit/ode/test_ode_feec.py similarity index 100% rename from src/struphy/ode/tests/test_ode_feec.py rename to src/struphy/tests/unit/ode/test_ode_feec.py diff --git a/src/struphy/pic/tests/__init__.py b/src/struphy/tests/unit/pic/__init__.py similarity index 100% rename from src/struphy/pic/tests/__init__.py rename to src/struphy/tests/unit/pic/__init__.py diff --git a/src/struphy/pic/tests/test_accum_vec_H1.py b/src/struphy/tests/unit/pic/test_accum_vec_H1.py similarity index 100% rename from src/struphy/pic/tests/test_accum_vec_H1.py rename to src/struphy/tests/unit/pic/test_accum_vec_H1.py diff --git a/src/struphy/pic/tests/test_accumulation.py b/src/struphy/tests/unit/pic/test_accumulation.py similarity index 99% rename from src/struphy/pic/tests/test_accumulation.py rename to src/struphy/tests/unit/pic/test_accumulation.py index ed3a41ff4..d889b7342 100644 --- a/src/struphy/pic/tests/test_accumulation.py +++ b/src/struphy/tests/unit/pic/test_accumulation.py @@ -61,8 +61,8 @@ def pc_lin_mhd_6d_step_ph_full(Nel, p, spl_kind, mapping, Np, verbose=False): from struphy.pic.accumulation import accum_kernels from struphy.pic.accumulation.particles_to_grid import Accumulator from struphy.pic.particles import Particles6D - from struphy.pic.tests.test_pic_legacy_files.accumulation_kernels_3d import kernel_step_ph_full from struphy.pic.utilities import BoundaryParameters, LoadingParameters, WeightsParameters + from struphy.tests.unit.pic.test_pic_legacy_files.accumulation_kernels_3d import kernel_step_ph_full if isinstance(MPI.COMM_WORLD, MockComm): mpi_comm = None diff --git a/src/struphy/pic/tests/test_binning.py b/src/struphy/tests/unit/pic/test_binning.py similarity index 100% rename from src/struphy/pic/tests/test_binning.py rename to src/struphy/tests/unit/pic/test_binning.py diff --git a/src/struphy/pic/tests/test_draw_parallel.py b/src/struphy/tests/unit/pic/test_draw_parallel.py similarity index 100% rename from src/struphy/pic/tests/test_draw_parallel.py rename to src/struphy/tests/unit/pic/test_draw_parallel.py diff --git a/src/struphy/pic/tests/test_mat_vec_filler.py b/src/struphy/tests/unit/pic/test_mat_vec_filler.py similarity index 100% rename from src/struphy/pic/tests/test_mat_vec_filler.py rename to src/struphy/tests/unit/pic/test_mat_vec_filler.py diff --git a/src/struphy/pic/tests/test_pic_legacy_files/__init__.py b/src/struphy/tests/unit/pic/test_pic_legacy_files/__init__.py similarity index 100% rename from src/struphy/pic/tests/test_pic_legacy_files/__init__.py rename to src/struphy/tests/unit/pic/test_pic_legacy_files/__init__.py diff --git a/src/struphy/pic/tests/test_pic_legacy_files/accumulation.py b/src/struphy/tests/unit/pic/test_pic_legacy_files/accumulation.py similarity index 98% rename from src/struphy/pic/tests/test_pic_legacy_files/accumulation.py rename to src/struphy/tests/unit/pic/test_pic_legacy_files/accumulation.py index 6bb225571..bf196159c 100644 --- a/src/struphy/pic/tests/test_pic_legacy_files/accumulation.py +++ b/src/struphy/tests/unit/pic/test_pic_legacy_files/accumulation.py @@ -12,11 +12,11 @@ import scipy.sparse as spa from psydac.ddm.mpi import mpi as MPI -import struphy.pic.tests.test_pic_legacy_files.accumulation_kernels_3d as pic_ker_3d +import struphy.tests.unit.pic.test_pic_legacy_files.accumulation_kernels_3d as pic_ker_3d -# import struphy.pic.tests.test_pic_legacy_files.accumulation_kernels_2d as pic_ker_2d +# import struphy.tests.unit.pic.test_pic_legacy_files.accumulation_kernels_2d as pic_ker_2d -# from struphy.pic.tests.test_pic_legacy_files.control_variate import TermsControlVariate +# from struphy.tests.unit.pic.test_pic_legacy_files.control_variate import TermsControlVariate class Accumulator: diff --git a/src/struphy/pic/tests/test_pic_legacy_files/accumulation_kernels_3d.py b/src/struphy/tests/unit/pic/test_pic_legacy_files/accumulation_kernels_3d.py similarity index 99% rename from src/struphy/pic/tests/test_pic_legacy_files/accumulation_kernels_3d.py rename to src/struphy/tests/unit/pic/test_pic_legacy_files/accumulation_kernels_3d.py index 349cca379..09033cc2a 100644 --- a/src/struphy/pic/tests/test_pic_legacy_files/accumulation_kernels_3d.py +++ b/src/struphy/tests/unit/pic/test_pic_legacy_files/accumulation_kernels_3d.py @@ -4,8 +4,8 @@ import struphy.linear_algebra.linalg_kernels as linalg # import module for mapping evaluation -import struphy.pic.tests.test_pic_legacy_files.mappings_3d_fast as mapping_fast -import struphy.pic.tests.test_pic_legacy_files.spline_evaluation_3d as eva3 +import struphy.tests.unit.pic.test_pic_legacy_files.mappings_3d_fast as mapping_fast +import struphy.tests.unit.pic.test_pic_legacy_files.spline_evaluation_3d as eva3 # ============================================================================== diff --git a/src/struphy/pic/tests/test_pic_legacy_files/mappings_3d.py b/src/struphy/tests/unit/pic/test_pic_legacy_files/mappings_3d.py similarity index 99% rename from src/struphy/pic/tests/test_pic_legacy_files/mappings_3d.py rename to src/struphy/tests/unit/pic/test_pic_legacy_files/mappings_3d.py index 2e54d34dd..b27257eaf 100644 --- a/src/struphy/pic/tests/test_pic_legacy_files/mappings_3d.py +++ b/src/struphy/tests/unit/pic/test_pic_legacy_files/mappings_3d.py @@ -28,8 +28,8 @@ from numpy import arcsin, arctan2, cos, empty, pi, shape, sin, sqrt -import struphy.pic.tests.test_pic_legacy_files.spline_evaluation_2d as eva_2d -import struphy.pic.tests.test_pic_legacy_files.spline_evaluation_3d as eva_3d +import struphy.tests.unit.pic.test_pic_legacy_files.spline_evaluation_2d as eva_2d +import struphy.tests.unit.pic.test_pic_legacy_files.spline_evaluation_3d as eva_3d # ======================================================================= diff --git a/src/struphy/pic/tests/test_pic_legacy_files/mappings_3d_fast.py b/src/struphy/tests/unit/pic/test_pic_legacy_files/mappings_3d_fast.py similarity index 98% rename from src/struphy/pic/tests/test_pic_legacy_files/mappings_3d_fast.py rename to src/struphy/tests/unit/pic/test_pic_legacy_files/mappings_3d_fast.py index f87380685..fde6edd69 100644 --- a/src/struphy/pic/tests/test_pic_legacy_files/mappings_3d_fast.py +++ b/src/struphy/tests/unit/pic/test_pic_legacy_files/mappings_3d_fast.py @@ -9,9 +9,9 @@ from numpy import cos, empty, pi, sin import struphy.bsplines.bsplines_kernels as bsp -import struphy.pic.tests.test_pic_legacy_files.mappings_3d as mapping -from struphy.pic.tests.test_pic_legacy_files.spline_evaluation_2d import evaluation_kernel_2d -from struphy.pic.tests.test_pic_legacy_files.spline_evaluation_3d import evaluation_kernel_3d +import struphy.tests.unit.pic.test_pic_legacy_files.mappings_3d as mapping +from struphy.tests.unit.pic.test_pic_legacy_files.spline_evaluation_2d import evaluation_kernel_2d +from struphy.tests.unit.pic.test_pic_legacy_files.spline_evaluation_3d import evaluation_kernel_3d # ========================================================================== diff --git a/src/struphy/pic/tests/test_pic_legacy_files/pusher.py b/src/struphy/tests/unit/pic/test_pic_legacy_files/pusher.py similarity index 98% rename from src/struphy/pic/tests/test_pic_legacy_files/pusher.py rename to src/struphy/tests/unit/pic/test_pic_legacy_files/pusher.py index 518e19ee0..9e6a898fd 100644 --- a/src/struphy/pic/tests/test_pic_legacy_files/pusher.py +++ b/src/struphy/tests/unit/pic/test_pic_legacy_files/pusher.py @@ -1,8 +1,8 @@ import cunumpy as xp -import struphy.pic.tests.test_pic_legacy_files.pusher_pos as push_pos -import struphy.pic.tests.test_pic_legacy_files.pusher_vel_2d as push_vel_2d -import struphy.pic.tests.test_pic_legacy_files.pusher_vel_3d as push_vel_3d +import struphy.tests.unit.pic.test_pic_legacy_files.pusher_pos as push_pos +import struphy.tests.unit.pic.test_pic_legacy_files.pusher_vel_2d as push_vel_2d +import struphy.tests.unit.pic.test_pic_legacy_files.pusher_vel_3d as push_vel_3d class Pusher: diff --git a/src/struphy/pic/tests/test_pic_legacy_files/pusher_pos.py b/src/struphy/tests/unit/pic/test_pic_legacy_files/pusher_pos.py similarity index 99% rename from src/struphy/pic/tests/test_pic_legacy_files/pusher_pos.py rename to src/struphy/tests/unit/pic/test_pic_legacy_files/pusher_pos.py index 81b5e1e53..386a37712 100644 --- a/src/struphy/pic/tests/test_pic_legacy_files/pusher_pos.py +++ b/src/struphy/tests/unit/pic/test_pic_legacy_files/pusher_pos.py @@ -8,9 +8,9 @@ import struphy.linear_algebra.linalg_kernels as linalg # import modules for mapping evaluation -import struphy.pic.tests.test_pic_legacy_files.mappings_3d as mapping -import struphy.pic.tests.test_pic_legacy_files.mappings_3d_fast as mapping_fast -import struphy.pic.tests.test_pic_legacy_files.spline_evaluation_3d as eva3 +import struphy.tests.unit.pic.test_pic_legacy_files.mappings_3d as mapping +import struphy.tests.unit.pic.test_pic_legacy_files.mappings_3d_fast as mapping_fast +import struphy.tests.unit.pic.test_pic_legacy_files.spline_evaluation_3d as eva3 # ========================================================================================================== diff --git a/src/struphy/pic/tests/test_pic_legacy_files/pusher_vel_2d.py b/src/struphy/tests/unit/pic/test_pic_legacy_files/pusher_vel_2d.py similarity index 99% rename from src/struphy/pic/tests/test_pic_legacy_files/pusher_vel_2d.py rename to src/struphy/tests/unit/pic/test_pic_legacy_files/pusher_vel_2d.py index 0fcc29751..74e67f708 100644 --- a/src/struphy/pic/tests/test_pic_legacy_files/pusher_vel_2d.py +++ b/src/struphy/tests/unit/pic/test_pic_legacy_files/pusher_vel_2d.py @@ -8,8 +8,8 @@ import struphy.linear_algebra.linalg_kernels as linalg # import modules for mapping evaluation -import struphy.pic.tests.test_pic_legacy_files.mappings_3d_fast as mapping_fast -import struphy.pic.tests.test_pic_legacy_files.spline_evaluation_2d as eva2 +import struphy.tests.unit.pic.test_pic_legacy_files.mappings_3d_fast as mapping_fast +import struphy.tests.unit.pic.test_pic_legacy_files.spline_evaluation_2d as eva2 # ========================================================================================================== diff --git a/src/struphy/pic/tests/test_pic_legacy_files/pusher_vel_3d.py b/src/struphy/tests/unit/pic/test_pic_legacy_files/pusher_vel_3d.py similarity index 99% rename from src/struphy/pic/tests/test_pic_legacy_files/pusher_vel_3d.py rename to src/struphy/tests/unit/pic/test_pic_legacy_files/pusher_vel_3d.py index cd3884209..adec27a41 100644 --- a/src/struphy/pic/tests/test_pic_legacy_files/pusher_vel_3d.py +++ b/src/struphy/tests/unit/pic/test_pic_legacy_files/pusher_vel_3d.py @@ -8,8 +8,8 @@ import struphy.linear_algebra.linalg_kernels as linalg # import modules for mapping evaluation -import struphy.pic.tests.test_pic_legacy_files.mappings_3d_fast as mapping_fast -import struphy.pic.tests.test_pic_legacy_files.spline_evaluation_3d as eva3 +import struphy.tests.unit.pic.test_pic_legacy_files.mappings_3d_fast as mapping_fast +import struphy.tests.unit.pic.test_pic_legacy_files.spline_evaluation_3d as eva3 # ========================================================================================================== diff --git a/src/struphy/pic/tests/test_pic_legacy_files/spline_evaluation_2d.py b/src/struphy/tests/unit/pic/test_pic_legacy_files/spline_evaluation_2d.py similarity index 100% rename from src/struphy/pic/tests/test_pic_legacy_files/spline_evaluation_2d.py rename to src/struphy/tests/unit/pic/test_pic_legacy_files/spline_evaluation_2d.py diff --git a/src/struphy/pic/tests/test_pic_legacy_files/spline_evaluation_3d.py b/src/struphy/tests/unit/pic/test_pic_legacy_files/spline_evaluation_3d.py similarity index 100% rename from src/struphy/pic/tests/test_pic_legacy_files/spline_evaluation_3d.py rename to src/struphy/tests/unit/pic/test_pic_legacy_files/spline_evaluation_3d.py diff --git a/src/struphy/pic/tests/test_pushers.py b/src/struphy/tests/unit/pic/test_pushers.py similarity index 98% rename from src/struphy/pic/tests/test_pushers.py rename to src/struphy/tests/unit/pic/test_pushers.py index 321ab9aba..5da375fd3 100644 --- a/src/struphy/pic/tests/test_pushers.py +++ b/src/struphy/tests/unit/pic/test_pushers.py @@ -34,8 +34,8 @@ def test_push_vxb_analytic(Nel, p, spl_kind, mapping, show_plots=False): from struphy.pic.particles import Particles6D from struphy.pic.pushing import pusher_kernels from struphy.pic.pushing.pusher import Pusher as Pusher_psy - from struphy.pic.tests.test_pic_legacy_files.pusher import Pusher as Pusher_str from struphy.pic.utilities import BoundaryParameters, LoadingParameters, WeightsParameters + from struphy.tests.unit.pic.test_pic_legacy_files.pusher import Pusher as Pusher_str comm = MPI.COMM_WORLD rank = comm.Get_rank() @@ -170,8 +170,8 @@ def test_push_bxu_Hdiv(Nel, p, spl_kind, mapping, show_plots=False): from struphy.pic.particles import Particles6D from struphy.pic.pushing import pusher_kernels from struphy.pic.pushing.pusher import Pusher as Pusher_psy - from struphy.pic.tests.test_pic_legacy_files.pusher import Pusher as Pusher_str from struphy.pic.utilities import BoundaryParameters, LoadingParameters, WeightsParameters + from struphy.tests.unit.pic.test_pic_legacy_files.pusher import Pusher as Pusher_str comm = MPI.COMM_WORLD rank = comm.Get_rank() @@ -317,8 +317,8 @@ def test_push_bxu_Hcurl(Nel, p, spl_kind, mapping, show_plots=False): from struphy.pic.particles import Particles6D from struphy.pic.pushing import pusher_kernels from struphy.pic.pushing.pusher import Pusher as Pusher_psy - from struphy.pic.tests.test_pic_legacy_files.pusher import Pusher as Pusher_str from struphy.pic.utilities import BoundaryParameters, LoadingParameters, WeightsParameters + from struphy.tests.unit.pic.test_pic_legacy_files.pusher import Pusher as Pusher_str comm = MPI.COMM_WORLD rank = comm.Get_rank() @@ -464,8 +464,8 @@ def test_push_bxu_H1vec(Nel, p, spl_kind, mapping, show_plots=False): from struphy.pic.particles import Particles6D from struphy.pic.pushing import pusher_kernels from struphy.pic.pushing.pusher import Pusher as Pusher_psy - from struphy.pic.tests.test_pic_legacy_files.pusher import Pusher as Pusher_str from struphy.pic.utilities import BoundaryParameters, LoadingParameters, WeightsParameters + from struphy.tests.unit.pic.test_pic_legacy_files.pusher import Pusher as Pusher_str comm = MPI.COMM_WORLD rank = comm.Get_rank() @@ -611,8 +611,8 @@ def test_push_bxu_Hdiv_pauli(Nel, p, spl_kind, mapping, show_plots=False): from struphy.pic.particles import Particles6D from struphy.pic.pushing import pusher_kernels from struphy.pic.pushing.pusher import Pusher as Pusher_psy - from struphy.pic.tests.test_pic_legacy_files.pusher import Pusher as Pusher_str from struphy.pic.utilities import BoundaryParameters, LoadingParameters, WeightsParameters + from struphy.tests.unit.pic.test_pic_legacy_files.pusher import Pusher as Pusher_str comm = MPI.COMM_WORLD rank = comm.Get_rank() @@ -761,8 +761,8 @@ def test_push_eta_rk4(Nel, p, spl_kind, mapping, show_plots=False): from struphy.pic.particles import Particles6D from struphy.pic.pushing import pusher_kernels from struphy.pic.pushing.pusher import Pusher as Pusher_psy - from struphy.pic.tests.test_pic_legacy_files.pusher import Pusher as Pusher_str from struphy.pic.utilities import BoundaryParameters, LoadingParameters, WeightsParameters + from struphy.tests.unit.pic.test_pic_legacy_files.pusher import Pusher as Pusher_str comm = MPI.COMM_WORLD rank = comm.Get_rank() diff --git a/src/struphy/pic/tests/test_sorting.py b/src/struphy/tests/unit/pic/test_sorting.py similarity index 100% rename from src/struphy/pic/tests/test_sorting.py rename to src/struphy/tests/unit/pic/test_sorting.py diff --git a/src/struphy/pic/tests/test_sph.py b/src/struphy/tests/unit/pic/test_sph.py similarity index 100% rename from src/struphy/pic/tests/test_sph.py rename to src/struphy/tests/unit/pic/test_sph.py diff --git a/src/struphy/pic/tests/test_tesselation.py b/src/struphy/tests/unit/pic/test_tesselation.py similarity index 100% rename from src/struphy/pic/tests/test_tesselation.py rename to src/struphy/tests/unit/pic/test_tesselation.py diff --git a/src/struphy/polar/tests/__init__.py b/src/struphy/tests/unit/polar/__init__.py similarity index 100% rename from src/struphy/polar/tests/__init__.py rename to src/struphy/tests/unit/polar/__init__.py diff --git a/src/struphy/polar/tests/test_legacy_polar_splines.py b/src/struphy/tests/unit/polar/test_legacy_polar_splines.py similarity index 100% rename from src/struphy/polar/tests/test_legacy_polar_splines.py rename to src/struphy/tests/unit/polar/test_legacy_polar_splines.py diff --git a/src/struphy/polar/tests/test_polar.py b/src/struphy/tests/unit/polar/test_polar.py similarity index 100% rename from src/struphy/polar/tests/test_polar.py rename to src/struphy/tests/unit/polar/test_polar.py diff --git a/src/struphy/propagators/tests/__init__.py b/src/struphy/tests/unit/propagators/__init__.py similarity index 100% rename from src/struphy/propagators/tests/__init__.py rename to src/struphy/tests/unit/propagators/__init__.py diff --git a/src/struphy/propagators/tests/test_gyrokinetic_poisson.py b/src/struphy/tests/unit/propagators/test_gyrokinetic_poisson.py similarity index 100% rename from src/struphy/propagators/tests/test_gyrokinetic_poisson.py rename to src/struphy/tests/unit/propagators/test_gyrokinetic_poisson.py diff --git a/src/struphy/propagators/tests/test_poisson.py b/src/struphy/tests/unit/propagators/test_poisson.py similarity index 100% rename from src/struphy/propagators/tests/test_poisson.py rename to src/struphy/tests/unit/propagators/test_poisson.py diff --git a/src/struphy/utils/test_clone_config.py b/src/struphy/tests/unit/utils/test_clone_config.py similarity index 100% rename from src/struphy/utils/test_clone_config.py rename to src/struphy/tests/unit/utils/test_clone_config.py diff --git a/src/struphy/models/tests/test_verif_EulerSPH.py b/src/struphy/tests/verification/test_verif_EulerSPH.py similarity index 100% rename from src/struphy/models/tests/test_verif_EulerSPH.py rename to src/struphy/tests/verification/test_verif_EulerSPH.py diff --git a/src/struphy/models/tests/test_verif_LinearMHD.py b/src/struphy/tests/verification/test_verif_LinearMHD.py similarity index 100% rename from src/struphy/models/tests/test_verif_LinearMHD.py rename to src/struphy/tests/verification/test_verif_LinearMHD.py diff --git a/src/struphy/models/tests/test_verif_Maxwell.py b/src/struphy/tests/verification/test_verif_Maxwell.py similarity index 100% rename from src/struphy/models/tests/test_verif_Maxwell.py rename to src/struphy/tests/verification/test_verif_Maxwell.py diff --git a/src/struphy/models/tests/test_verif_Poisson.py b/src/struphy/tests/verification/test_verif_Poisson.py similarity index 100% rename from src/struphy/models/tests/test_verif_Poisson.py rename to src/struphy/tests/verification/test_verif_Poisson.py diff --git a/src/struphy/models/tests/test_verif_VlasovAmpereOneSpecies.py b/src/struphy/tests/verification/test_verif_VlasovAmpereOneSpecies.py similarity index 100% rename from src/struphy/models/tests/test_verif_VlasovAmpereOneSpecies.py rename to src/struphy/tests/verification/test_verif_VlasovAmpereOneSpecies.py diff --git a/src/struphy/utils/utils.py b/src/struphy/utils/utils.py index 171b61c23..38d910eda 100644 --- a/src/struphy/utils/utils.py +++ b/src/struphy/utils/utils.py @@ -195,6 +195,7 @@ def subp_run(cmd, cwd="libpath", check=True): cwd = struphy.__path__[0] print(f"\nRunning the following command as a subprocess:\n{' '.join(cmd)}") + print(f"Running in directory: {cwd}") subprocess.run(cmd, cwd=cwd, check=check)