Code Contribution Guide
You can contribute by reporting a bug, suggesting a feature, improving the documentation, or changing the code.
This guide covers the MATLAB and Python repositories in the uwa-channels organization:
| Repository | Language | Main Branch | Folder Layout |
|---|---|---|---|
| uwa-channels/matlab | MATLAB (R2021a+) | main | src/, tests/, examples/, packaging/ |
| uwa-channels/python | Python (≥ 3.10) | main | src/uwa_channels/, tests/, examples/ |
The library’s Julia support is hosted separately, in the UnderwaterAcoustics.jl package maintained by the Acoustic Research Laboratory. Please refer to that repository’s own contribution guidelines for Julia-specific bug reports and pull requests.
The MATLAB and Python implementations must produce consistent results. The calibration suite checks this weekly by running both implementations on the released Zenodo files.
If you change a function’s behavior, make the corresponding change in both repositories. Keep argument order, output length, and indexing conventions consistent with each API. In particular, array_index starts at 1 in MATLAB and at 0 in Python; preserve the existing convention for start as well. The released .mat files are fixed, so changes must remain compatible with them.
Getting started
Prerequisites
Familiarity with Git, GitHub, Markdown, and either MATLAB or Python.
Helpful references: GitHub Quickstart, Markdown Guide.Development environment:
MATLAB repository
git clone https://github.com/uwa-channels/matlab.gitTo run example scripts, first download
blue_1.matandblue_noise.matfrom Zenodo intoexamples/, then:addpath('src') cd examples example_replayTo run all tests from the repository root (they use
matlab.unittest, so they need MATLAB with the Signal Processing Toolbox):matlab -batch "addpath('src'); assertSuccess(runtests('tests'))"Python repository: create a virtual environment and install dependencies:
git clone https://github.com/uwa-channels/python.git cd python pip install -r requirements.txt pytest pre-commitTo run example scripts, with
blue_1.matandblue_noise.matfrom Zenodo in the working folder:PYTHONPATH=src python examples/example_replay.pyTo run tests:
PYTHONPATH=src pytestThe tests in
tests/test_zenodo.pyreplay the released Zenodo files and are skipped by default. Run them with the command below; they download the files to$UWA_CHANNELS_CACHE, or to~/.cache/uwa-channels:PYTHONPATH=src pytest tests/test_zenodo.py --zenodoTo initialize
pre-commit:pre-commit install pre-commit run --all-files
Code of conduct
Treat other contributors respectfully and keep feedback constructive.
Bug reports, feature requests, and discussions
Bug reports
- Search existing issues and pull requests; your bug may already be reported or fixed.
- Provide a minimal, reproducible example (MATLAB
.mfile or live script, or a Python snippet), along with:- Package version:
pip show uwa-channelsin Python; in MATLAB, theUnderwater Acoustic Channel Toolboxrow ofmatlab.addons.installedAddons, or theVERSIONfile in a clone - OS and MATLAB/Python version, if relevant
- Package version:
Feature requests
Explain what you want to do, why it matters, and how the proposed change would help. Include an example API or workflow if useful.
Discussions
Use GitHub Discussions for questions, design ideas, and future plans.
Issue labels
| Label | Meaning |
|---|---|
high-priority / low-priority | Relative urgency |
good first issue | Suitable for newcomers |
breaking-change | API/behavior change |
Issues planned for release are tracked with a GitHub milestone rather than a label.
Workflow for code and documentation changes
- Fork the repository and clone your fork.
- Create a branch from
main, named liketopic-short-description(lowercase, hyphen-separated). - Develop locally:
- MATLAB: run
addpath('src'); runtests('tests')from the repository root and address Code Analyzer warnings. - Python: run
PYTHONPATH=src pytestfrequently.
- MATLAB: run
- Write tests for new features or bug fixes.
- Document your changes:
- Use NumPy-style docstrings in Python functions and classes.
- Start each MATLAB function with a help block (H1 line, call forms, inputs, outputs, an example, and a dated revision history), and add a line to the revision history when you change its behavior.
- Commit with clear messages, then push to your fork.
- Open a pull request (PR) against
main. Mark it as “Draft” if it’s not yet ready for review. Reference any related issues. - Address reviewer feedback. Once all checks pass and approvals are received, a maintainer will merge.
Commit message style
Start each commit message with a verb and describe the change. For example:
Start the f_resamp phase ramp at zero, and test that it does
Read MAT v5 files, and fix the beta axis order from h5py
Coding standards
MATLAB
Follow the MATLAB Style Guide:
- Four-space indentation, as MATLAB’s Smart Indent applies it;
snake_casefor functions,PascalCasefor classes - Each function/class in its own
.mfile - Keep
src/working on MATLAB R2021a: validate inputs withassertin avalidate_inputssubfunction rather than withargumentsblocks - Add unit tests as flat files directly under
tests/using MATLAB Unit Test - Vectorize where possible; comment non-obvious logic
Python
- Formatting is enforced via Black and Ruff at 88 columns (Ruff handles import sorting, so a separate isort pass is unnecessary)
- Static analysis via Flake8, Ruff, mypy, and Bandit
- Use NumPy-style docstrings with LaTeX equations where helpful
- Validate public function inputs with
validate_inputsbefore processing. Match the checks in the MATLAB implementation and raiseValueErrorfor invalid inputs. Do not useassertfor validation; Python removes it when run with-O. - Keep functions short, prefer clarity to cleverness, and avoid premature optimization
Equations in documentation
The same formula needs different delimiters on GitHub and on this site.
- In Markdown that GitHub renders, such as
CONTRIBUTING.mdin the MATLAB and Python repositories, write inline math as$`\hat\varphi(nT_s)`$and display math in a fenced```mathblock. A bare$...$lets GitHub’s Markdown run first, which turns_into emphasis and\,into a comma, and<inside math should be written\lt. - On this site, write
$...$and$$...$$. Hugo renders them with its bundled KaTeX when it builds the site, andparams.katex.versioninconfig.tomlmust name that same KaTeX version, or rules such as the underline in are not drawn. The build checks this withtools/check_katex_css.py.
Testing and continuous integration
| Repository | Local Test Command | CI Matrix |
|---|---|---|
| MATLAB | matlab -batch "addpath('src'); assertSuccess(runtests('tests'))" | MATLAB R2021a and latest |
| Python | PYTHONPATH=src pytest | Python 3.10–3.13; Zenodo tests on 3.13 |
All CI checks must pass before a pull request is merged.
Release process
Both repositories follow Semantic Versioning. Do not change the version in a pull request unless a maintainer asks for a release.
- MATLAB: bump
VERSIONand theversioninCITATION.cfftogether, then push a tagvX.Y.Zthat matchesVERSION. The release workflow buildsuwa-channels.mltbxon the latest MATLAB, checks that it installs there and on R2021a, attaches it to a GitHub release, and checks that the one-line install works against it. - Python: bump
versioninpyproject.tomland inCITATION.cfftogether onmain. CI then creates the tagvX.Y.Z, publishes a GitHub release with signed distributions, and uploads the package to TestPyPI and PyPI.
Acknowledgements
This guide draws on the UnderwaterAcoustics.jl contributing guide, as well as the contribution guidelines of NumPy and SciPy, and the MATLAB Style Guide.