Skip to content
Closed
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f4bd5f7
Update action.yml
max-models Oct 24, 2025
62253e4
Update action.yml
max-models Oct 24, 2025
810916c
Merge branch 'devel' into 45-only-run-the-unit-tests-which-touch-chan…
max-models Oct 24, 2025
8843cac
Update action.yml
max-models Oct 25, 2025
4cdb2da
Added --testmon to unit tests
max-models Oct 25, 2025
7bdb667
Removed -k from unit tests
max-models Oct 26, 2025
5dbc99e
Put testmon data in cache
max-models Oct 26, 2025
03adb04
Continue if no testmondata is found
max-models Oct 26, 2025
20f978d
Added struphy_verification_tests/ to .gitignore
max-models Oct 26, 2025
6343bf3
--ignore=model/tests
max-models Oct 26, 2025
d5f638b
Check testmon from devel before any other branch.
max-models Oct 26, 2025
ca13950
Added TESTMON_DATAFILE to env
max-models Oct 26, 2025
ac2b016
Added caching of .testmondata at the end of the pipeline
max-models Oct 26, 2025
e033901
Set concurrency with cancel-in-progress: true
max-models Oct 26, 2025
ab9e96e
Moved verification tests into verification/
max-models Oct 26, 2025
0a72627
Specify tests with paths
max-models Oct 26, 2025
97ecf4c
FOrmatting
max-models Oct 26, 2025
d201a74
Moved one unit test
max-models Oct 26, 2025
4cf0c85
Formatting
max-models Oct 26, 2025
768bce9
Removed everything other than the unit test in the CI
max-models Oct 26, 2025
decfd63
Trigger CI
max-models Oct 26, 2025
c69b28c
Moved model tests to tests/model
max-models Oct 26, 2025
c396007
Moved verification tests to tests/verification
max-models Oct 26, 2025
0b82265
Moved all tests into tests/
max-models Oct 26, 2025
5cb8586
Moved the last test
max-models Oct 26, 2025
6a5f232
Fixed incorrect import
max-models Oct 26, 2025
d9a02e9
Removed duplicate testing
max-models Oct 26, 2025
91b8ab7
Cleanup test.py
max-models Oct 26, 2025
8405f95
Separate the cached testmondata depending on the test-type so we aren…
max-models Oct 26, 2025
0c620c4
Cleanup
max-models Oct 26, 2025
f4ce7f8
Fix imports
max-models Oct 26, 2025
1d2502f
Commented out MPI test with --testmon
max-models Oct 26, 2025
cb02222
Formatting
max-models Oct 26, 2025
6b27161
Fixed ls testmon*
max-models Oct 26, 2025
ba29fde
Split unit tests from unit-mpi
max-models Oct 26, 2025
c1f9931
Cleanup
max-models Oct 26, 2025
3de56a4
Run all unit tests
max-models Oct 26, 2025
0905d6e
Skip unit-mpi
max-models Oct 26, 2025
9a0f929
Added conftest.py to the package
max-models Oct 26, 2025
9fc5284
Uncommented MPI unit tests
max-models Oct 27, 2025
e80c507
only run tests/unit/bsplines/ in unit tests
max-models Oct 29, 2025
f4b1228
temp
max-models Oct 29, 2025
ff055b6
Merge branch 'devel' into 45-only-run-the-unit-tests-which-touch-chan…
max-models Oct 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/actions/compile/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ runs:
struphy compile -d -y &&
struphy compile -y --language ${{ matrix.compile-language }}
)
struphy compile --status
struphy --refresh-models

10 changes: 10 additions & 0 deletions .github/actions/tests/unit-mpi/action.yml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 7 additions & 9 deletions .github/actions/tests/unit/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions .github/workflows/macos-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 27 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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'
Expand All @@ -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 }}
6 changes: 3 additions & 3 deletions .github/workflows/ubuntu-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ dependencies = [
'argcomplete',
'pytest',
'pytest-mpi',
'pytest-testmon',
'line_profiler',
]

Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -182,3 +184,5 @@ markers = [
"hybrid",
"single",
]


43 changes: 29 additions & 14 deletions src/struphy/console/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import os

import struphy
from struphy.utils.utils import subp_run

LIBPATH = struphy.__path__[0]


def struphy_test(
group: str,
Expand Down Expand Up @@ -41,15 +46,15 @@ def struphy_test(
"-n",
str(mpi),
"pytest",
"-k",
"not _models and not _tutorial and not pproc",
# "--testmon",
"--with-mpi",
f"{LIBPATH}/tests/unit/",
]
else:
cmd = [
"pytest",
"-k",
"not _models and not _tutorial and not pproc",
"--testmon",
f"{LIBPATH}/tests/unit/",
]

if with_desc:
Expand All @@ -59,6 +64,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"}:
Expand All @@ -69,21 +76,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:
Expand All @@ -92,6 +99,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:
Expand All @@ -102,17 +112,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:
Expand All @@ -121,6 +131,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:
Expand All @@ -130,11 +143,10 @@ def struphy_test(
"-n",
str(mpi),
"pytest",
"-k",
"_models",
"-m",
"single",
"-s",
# "--testmon",
"--with-mpi",
"--model-name",
group,
Expand All @@ -145,4 +157,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)
2 changes: 1 addition & 1 deletion src/struphy/linear_algebra/saddle_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it a bit odd to import a plotting function from a testing file, should it not be the opposite way around?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes i agree, please correct.



class SaddlePointSolver:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


# ==============================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


# =======================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


# ==========================================================================
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


# ==========================================================================================================
Expand Down
Loading
Loading