pylops/: library code.pytests/: pytest suite.docs/,examples/,tutorials/,testdata/: docs, examples, tutorial assets, and test data.pyproject.toml: build, test, lint, and packaging config.Makefile: preferred entry point for local work.
- Prefer
maketargets. Use the*_uvvariants when working in auvenvironment. - Common commands:
make dev-install_uv,make testsormake tests_uv,make lintormake lint_uv,make typeannotormake typeannot_uv,make docupdateormake docupdate_uv. - Packaging uses
hatchling; keep build and version settings inpyproject.toml.
- Follow the
ruffrules inpyproject.toml. - Keep imports tidy and follow PEP 8 rules.
- Follow
numpydocstyle for docstrings. - Add or update tests in
pytests/and examples inexamples/and/ortutorials/when changing behavior or public APIs.
Before writing a test, read an existing pytests/test_*.py for a similar operator (e.g. test_diagonal.py) and copy its structure.
- Define parameter sets at the top of the file as
par1,par1j, ... dicts (real/complex, fp32/fp64, sizes) and use@pytest.mark.parametrize("par", [(par1), (par1j)]). Never hardcode sizes, dtypes or flags inside the test body. - Use the backend-aware header (
TEST_CUPY_PYLOPS-> cupy/numpy,backend,assert_array_almost_equal). - Set
np.random.seed(...)at module level. Build inputs/matrices withnp.random.normal(pluspar["imag"] * ...for complex) rather than prescribed arrays likenp.arangeornp.ones. Use fixed values only when the expected result is analytic and random inputs cannot express it. - Every operator test includes a
dottest(explicit sizes, nevernp.prod) and, where invertible, an inversion check. - Failure-checking tests (
pytest.raises) go above normal tests in the file. - Match existing naming (
test_<Operator>_<case>) and one-line docstrings.
- Files in
examples/andtutorials/are gallery scripts rendered in the docs: noassert, nopytest, no correctness checks. Correctness belongs inpytests/. - Show results with plots/prints only and keep runtime short.
- Use
docs/source/contributing.rstas the source of truth for longer contribution workflows. - If functionality changes, update docs and run the relevant tests before handing off.
- Avoid editing generated artifacts or build output unless the task explicitly requires it.