🤝 Contributing to Time series Additive Model (TAM)¶
⬅️ README | 📚 THEORY | 📘 DOCS GUIDE | 🆕 CHANGELOG
Thank you for your interest in contributing to TAM! We welcome contributions from the community, whether you are a mathematician adding a new effect or meta-model, or a software engineer optimizing our PyTorch tensor operations.
To ensure the framework remains mathematically rigorous and computationally stable, we ask all contributors to strictly follow the guidelines below.
1. Where to Start¶
Check Existing Issues: Before starting to code, please check our [Issues tracker] to see if someone else is already working on the feature or bug.
Open a New Issue: If you want to add a new Meta-Model or Effect, please open an issue first to discuss the mathematical validity and implementation strategy with the maintainers.
2. The “Mirror Architecture” (Documentation)¶
Because TAM serves two distinct audiences (mathematicians and software engineers), we enforce a strict Mirror Architecture for our documentation. You must separate mathematical proofs from Python engineering.
When you add a new feature, you must write a pair of Markdown files:
🧠
math/(The Brain): Explains why the formula is exact. Contains the theory, LaTeX equations ($$...$$), theorems, and academic citations{cite:p}`key`. Do not put code here.💻
architecture/(The Hands): Explains how the Python script calculates the formula without crashing. Contains PyTorch implementation details, OOP structure, and VRAM management.
🏛️ Documentation Golden Rules¶
Read the full guide: Please read our detailed Documentation Generation Guide before writing documentation.
No Redundancy: The
architecture/files must never re-demonstrate the math. Link back to themath/files.Code Extraction: Do not hard-copy Python code into Markdown. Use the Sphinx
{literalinclude}directive to pull code dynamically from the source files.
3. Coding Standards¶
Our core engine is built for industrial-grade performance on massive datasets. If you are modifying the Python source code in src/tam/:
OOM Safety: Ensure your PyTorch implementations strictly respect Out-Of-Memory (OOM) safety protocols. Matrix operations across the group dimension must support dynamic chunking (
try/exceptmemory routing).Vectorization: Avoid standard Python
forloops. Exploit N-dimensional broadcasting and PyTorch tensorization.Docstrings: We use Google-style docstrings. Ensure your functions and classes are fully documented, as Sphinx uses
autodocandnapoleonto generate the API reference automatically.Extend the public API, never change it:
tests/test_api_contracts.pypins the signatures of the main models (StaticTAM,AdaptiveTAM,KalmanTAM,OperaTAM,HierarchicalTAM) and of the formula parser, and the naming ofdecompose_predictioncolumns andsummary()keys. Do not rename, remove, reorder or change the default of an existing parameter; add a keyword argument with a default after the existing ones. A deliberate API change updates the pin in the same commit and says so in the pull request.No
print()in new code: the library does not print; use warnings for something the user must act on, and exceptions for errors. A logging refactor of the existing code comes later.Headers and credit: every
.pyfile ofsrc/andtests/starts with the same SPDX header (SPDX-FileCopyrightText, then oneSPDX-FileContributor: Nameline per author, thenSPDX-License-Identifier; copy the header of a neighbouring file). Add anSPDX-FileContributorline, a name and nothing else, when you write a substantial part of a file; credit smaller contributions in the CHANGELOG.AUTHORS.mdtells who did what;tests/test_spdx_headers.pyfails on a file with another shape.Type Hinting: Use strict Python type hints (
typing) for all function arguments and return types.No Math in Code Comments: Keep inline Python comments focused strictly on software engineering (e.g., tensor shapes
# Shape: [B, T, D], VRAM allocation, PyTorch workarounds). Leave the mathematical proofs to themath/Markdown files.Chronological Tensor Alignment: When projecting Pandas DataFrames into PyTorch tensors for time-series formulas, row-adjacency must equal chronological adjacency. Always apply
.sort_values(date_col)before tensor stacking or truncating (e.g., before.groupby().head()), and re-sort the target Pandas indices chronologically before mapping tensor predictions back, to prevent silent row-scrambling on unsorted input.
5. Submitting a Pull Request (PR)¶
Fork the repository and create your branch from
main.Implement your feature and ensure your code follows the coding standards.
Write the documentation pair in the
math/andarchitecture/folders.Compile the docs locally: Run
build_docs.bat(Windows) orbuild_docs.sh(Linux/Mac) to ensure the HTML and PDFs compile perfectly without Sphinx or LaTeX warnings.Run the regression checks:
python tests/regression/run.pyrewritestests/regression/RESULTS.txtandRESULTS_EXP.txt;git diff tests/regression/shows what your change moved. If that is what you intended, commit the new file in your pull request and say why the numbers moved; theRegressionworkflow fails whenRESULTS.txtin the pull request is not the one the checks produce (a differentRESULTS_EXP.txtis only a warning) (seetests/regression/README.md).Submit your PR: Provide a clear description of the problem solved, the mathematical approach taken, and the performance implications.
6. Licence of Contributions and Sign-off (DCO)¶
By contributing, you agree that your contribution is licensed under the licence of the file it changes (LGPL-3.0-or-later for the code, see LICENSES/ and REUSE.toml for the data and documents).
Every commit must carry a sign-off line, which certifies the Developer Certificate of Origin 1.1:
Signed-off-by: Your Name <your.email@example.com>
git commit -s -m "short phrase" adds it. The DCO check of a pull request fails when a commit lacks it. How to fix a missing sign-off: docs/contributing/dco_howto.md.