Contributing¶
Thanks for your interest in Pysic-rs! The project values textbook-validated physics, fast Rust code, and clean, reproducible documentation.
Code of conduct¶
Be respectful and constructive. Help others level up — the library is meant to be a place to learn physics and numerical methods.
Development setup¶
git clone https://github.com/ThotDjehuty/pysic-rs.git
cd pysic-rs
pip install maturin
maturin develop # debug build — fast iteration
Adding a new algorithm¶
Create (or extend) the module under
src/<module>/.Implement the function following the existing style:
Pure Rust core operating on
&[f64]/&[num_complex::Complex64].Public re-export from the module’s
mod.rs.
If it belongs to a documented module, add the PyO3 binding in
src/<module>/python_bindings.rsand register it insrc/lib.rs.Add unit tests with closed-form reference values (see
src/special_functionsfor the pattern). No test → no merge.Add a documentation page under
docs/source/algorithms/or extend the API page underdocs/source/api/.
Proven-physics rule¶
Every formula must come from a proven, published source (textbook / standard reference). Experimental or research-pending models are not accepted. When in doubt, add the theorem name and reference to the docstring.
Running tests¶
cargo test # unit + integration
cargo test --test integration_tests
64 tests must pass (45 unit + 12 integration + 7 feature-independent… — the exact count is reported by cargo; the important thing is no failures).
Building documentation¶
cd docs
pip install -r requirements.txt
make html # or: sphinx-build -b html source build/html
open build/html/index.html
The docs use Sphinx + the Furo theme with myst-parser for the Markdown algorithm pages.
Numeric claims in docs should be reproducible from the code (they are checked by unit tests).
Code style¶
Rust:
rustfmt(default settings) + conventional comments.Python: follow the existing
__init__.py— clean aliases, no imports of private_core.No new external dependencies unless they’re in
Cargo.toml(keeps the wheel small and the build self-contained).Every commit compiles; run
cargo testbefore pushing.
Architecture¶
src/
├── lib.rs # crate root + PyO3 module registration
├── core.rs # error types (PysicError)
├── constants.rs # physical constants
├── special_functions.rs # Gamma, Bessel, Legendre, erf, zeta, Airy, Chebyshev
├── linalg.rs # Cholesky, LU, inverse, determinant, tensor ops
├── calculus.rs # gradient, Hessian, quadrature, interpolation
├── ode/ # RK4, RK45, implicit, symplectic integrators
├── pde/ # Schrödinger, Dirac, heat, wave, Poisson, Maxwell FDTD
├── fourier/ # FFT/IFFT, spectral derivatives, PSD, Welch
├── quantum/ # Pauli, density matrices, path integrals, propagators
├── general_relativity/ # metrics, Christoffel, Riemann, geodesics, ADM
├── gauge/ # SU(2)/SU(3), connections, Yang–Mills, instantons
├── classical/ # Hamiltonian, Lagrangian, rigid body
├── topology/ # Berry phase, Chern, winding numbers
├── em/ # Green's functions, radiation formulas
└── casimir/ # parallel plates, sphere, cylinders, Lifshitz
Documentation pages layout¶
docs/source/
├── index.rst # home page / toctree
├── getting-started.md # prerequisites, install, first import
├── installation.md # full build recipes, wheels, features
├── quickstart.md # runnable examples per module
├── algorithms/*.md # one page per module — math foundations
├── api/*.md # one page per module — function reference
├── theory/ # shared mathematical foundations
├── contributing.md
└── changelog.md
Review checklist for PRs¶
cargo testpasses (no failures)rustfmtcleanNew formula has a proven source referenced in the docstring
Docs updated (algorithm or API page)
No secrets/
historia//agent files committed