Testing¶
Running the tests¶
From the repo root:
pip install pytest pytest-xdist
python -m pytest -n auto # in parallel
python -m pytest -m "not slow" # skip the tests that take more than ~10 s
pytest.ini sets pythonpath = . and testpaths = tests, so the in-tree package is found without installing it and without
setting PYTHONPATH. One test (tests/test_import.py::test_no_multitrap_fixtures_built_at_import)
imports levisim in a fresh subprocess, which relies on Python putting the working directory on
sys.path; it fails if PYTHONSAFEPATH is set in the environment, unless levisim is installed.
The suite runs on every push and pull request through GitHub Actions
(.github/workflows/tests.yml).
What the suites cover¶
File |
Covers |
|---|---|
|
|
|
the package’s public export surface, pinned |
|
the physical constants re-exported from SciPy, and unit-conversion sanity |
|
regressions for three call sites that used to raise |
|
assembly of the drift matrix \(\mathbf A\) for the Linear Amplifier Model |
|
spectra from the seven calculation methods agree with each other |
|
noise vectors agree across methods (marked |
|
spectra against the Fortran reference data |
|
two-mode Gaussian-state measures (PPT, log-negativity, discord, witnesses) |
|
covariance dynamics, the multi-tone Floquet drive, the two-tone scheme, and traps built from the focal field |
|
the README showcase: each of its snippets runs (the stochastic one is marked |
|
covariance of filtered (propagating) cavity-output modes: frequency integration against a cascaded filter cavity, several cavity modes on one particle, and the worked example of Deplano et al. (2026), Eq. (S45) |
Two markers are registered in tests/conftest.py: slow (more than about 10 s) and
needs_power_series (needs a power-series pickle; the three small ones the suite uses ship with
the package, in levisim/multiphysics/power_series_data/).
The Fortran reference¶
fortran/ holds an independent Fortran implementation of the multiparticle spectra, and the
.dat files it wrote. tests/test_fortran_reference.py rebuilds the same 8 × 2 system in
levisim (the FORTRAN_8x2 fixture: eight particles with near-degenerate \(x\) and \(y\)
frequencies in pairs) and compares the heterodyne spectrum, the homodyne spectrum and all position
PSDs against FTanXYZ.dat, FTCBM.dat and FTanOPT.dat. Agreement is limited by the files
themselves: they are written with seven significant figures, and the measured maximum relative
difference is \(7.4 \times 10^{-7}\). The test is skipped when the data files are absent.
To regenerate the data, see fortran/README.md: make pairs (or equal, random) builds into
fortran/build/<variant>/, which needs gfortran and LAPACK.