Skip to content

Add pytest test suite and GitHub Actions CI - #161

Merged
yumorishita merged 2 commits into
masterfrom
feature/tests
Aug 14, 2026
Merged

Add pytest test suite and GitHub Actions CI#161
yumorishita merged 2 commits into
masterfrom
feature/tests

Conversation

@yumorishita

Copy link
Copy Markdown
Owner

Summary

LiCSBAS2 had no automated tests. This PR adds a pytest-based test suite and a GitHub Actions CI workflow. The whole suite needs no network and no real data, and runs in ~30 s (~5 s without the smoke marker).

  • Unit tests for all LiCSBAS_lib modules (tools, inv, loop, io, plot): coordinate conversions, SBAS design matrices, NSBAS inversion (recovering a forward-modeled velocity field, incl. an n_core=2 vs n_core=1 consistency check), loop closure, raw-binary/GAMMA-par/baselines I/O, GeoTIFF round-trips, and plot smoke tests.
  • End-to-end smoke tests (tests/test_bin_smoke.py, marker smoke): steps 11–16 and LiCSBAS_cum2vel.py run as subprocesses on a synthetic 10x10-px, 5-epoch, 7-ifg GEOCml dataset (tests/synth.py) with exactly loop-consistent phases from a known velocity field. The inverted velocity is checked against the truth within 0.1 mm/yr.
  • Known latent bugs are pinned with xfail(strict=True), to be fixed in separate PRs:
    • inv_lib.censored_lstsq / censored_lstsq2 call the nonexistent np.linalg.leastsq in their 1-D/single-column branch
    • censored_lstsq2 accesses B.shape[1] before the B.ndim check (IndexError for 1-D input)
    • io_lib.make_geotiff raises UnboundLocalError for dtypes other than float32/uint8
  • CI: micromamba with a CI-only conda-forge env file (.github/workflows/environment-ci.yml; LiCSBAS.yml is untouched), triggered on pushes and PRs to master, with environment caching.

Notes:

  • The synthetic dataset adds tiny deterministic noise (sigma = 0.0003 rad, seed 42) because step 12's reference selection treats exactly-zero loop-phase RMS as nodata — a situation that cannot occur with real data.
  • No packaging changes; LiCSBAS_lib is put on the import path by pytest.ini/conftest.py, so tests run without sourcing bashrc_LiCSBAS.sh.

Test plan

  • python -m pytest in the licsbas conda env: 85 passed, 4 xfailed in ~30 s
  • Same result with PYTHONPATH/MPLBACKEND unset (self-contained config)
  • CI job on this PR solves the conda-forge env and passes

🤖 Generated with Claude Code

- Unit tests for all LiCSBAS_lib modules (tools, inv, loop, io, plot):
  89 tests running in ~30 s with no network and no real data
- End-to-end smoke tests of steps 11-16 and LiCSBAS_cum2vel.py on a
  synthetic 10x10-px, 5-epoch dataset with a known velocity field;
  the inverted velocity is checked against the truth (atol 0.1 mm/yr)
- Known latent bugs (nonexistent np.linalg.leastsq in
  inv_lib.censored_lstsq*, UnboundLocalError in io_lib.make_geotiff)
  are pinned with xfail(strict=True) to be fixed in separate PRs
- CI workflow with micromamba (conda-forge) runs the suite on
  pushes and PRs to master

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@yumorishita
yumorishita merged commit dedc691 into master Aug 14, 2026
1 check passed
@yumorishita
yumorishita deleted the feature/tests branch August 14, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant