|
| 1 | +# Contributing to pcpostprocess |
| 2 | + |
| 3 | +Contributions to pcpostprocess are always welcome! |
| 4 | + |
| 5 | +We use [GIT](https://en.wikipedia.org/wiki/Git) and [GitHub](https://en.wikipedia.org/wiki/GitHub) to coordinate our work. |
| 6 | +When making changes, we try to follow the procedure below. |
| 7 | + |
| 8 | +1. **Discuss proposed changes before starting any work.** |
| 9 | + Before coding, always create an [issue](https://guides.github.com/features/issues/) and disucss the proposed work. |
| 10 | + Something similar may already exist, be under development, or have been proposed and rejected - so this can save valuable time. |
| 11 | + |
| 12 | +2. **Always work on branches**. |
| 13 | + Once the idea has been agreed upon, start coding in a new _branch_. |
| 14 | + If you're in the CardiacModelling team, you can create a [branch](https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/) in the main pcpostprocess repository. |
| 15 | + For outside contributions, you'll first need to [create a fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo). |
| 16 | + |
| 17 | + There are no rules for branch names, but try to make them relate to the issue, e.g. by including the issue number. |
| 18 | + |
| 19 | + Commit your changes to your branch with useful, descriptive commit messages. |
| 20 | + Remember, these messages are publicly visible and should still make sense in years to come. |
| 21 | + |
| 22 | +3. **Conform to style guidelines, and document every class, method, and method argument.** |
| 23 | + For more information, please see below. |
| 24 | + |
| 25 | + **Note: as of 2025-11-11, we are still in the process of making `pcpostprocess` confirm to this rule.** |
| 26 | + |
| 27 | +4. **Test locally, and ensure 100% test coverage** |
| 28 | + For more information, please see below. |
| 29 | + |
| 30 | + **Note: as of 2025-11-11, we are stillin the process of making `pcpostprocess` confirm to this rule.** |
| 31 | + |
| 32 | +4. **Discuss code in a PR** |
| 33 | + When your code is finished, or warrants discussion, create a [pull request](https://help.github.com/articles/about-pull-requests/) (PR). |
| 34 | + In your branch, update the [CHANGELOG.md](./CHANGELOG.MD) with a link to this PR and a concise summary of the changes. |
| 35 | + Finally, request a review of the code. |
| 36 | + |
| 37 | + |
| 38 | +## Project structure |
| 39 | + |
| 40 | +`pcpostprocess` is written in [Python 3](https://en.wikipedia.org/wiki/Python_(programming_language)), but at the moment has a few **non-python dependencies** i.e. latex. |
| 41 | + |
| 42 | +## Developer installation |
| 43 | + |
| 44 | +TODO: Once there is a "user" way to install, move the git clone etc. information here. |
| 45 | + |
| 46 | +``` |
| 47 | +pip install -e .[test] |
| 48 | +``` |
| 49 | + |
| 50 | +## Style guidelines |
| 51 | + |
| 52 | +Style checking is done with [flake8](http://flake8.pycqa.org/en/latest/). |
| 53 | + |
| 54 | +To run locally, use |
| 55 | +``` |
| 56 | +$ flake8 |
| 57 | +``` |
| 58 | + |
| 59 | +Until Flake8 configuration supports [pyproject.toml](https://github.com/PyCQA/flake8/issues/234), it will be configured through [.flake8](./.flake8) ([syntax](http://flake8.pycqa.org/en/latest/user/configuration.html)). |
| 60 | + |
| 61 | +In addition to the rules checked by flake8, we try to use single quotes (`'`) for strings, rather than double quotes (`"`) (but `"""` for docstrings). |
| 62 | + |
| 63 | +### Spelling |
| 64 | + |
| 65 | +TODO WE SHOULD MAYBE DISCUSS WHICH ENGLISH TO USE? |
| 66 | + |
| 67 | +### Import ordering |
| 68 | + |
| 69 | +Import ordering is tested with [isort](https://pycqa.github.io/isort/index.html). |
| 70 | + |
| 71 | +To run locally, use |
| 72 | +``` |
| 73 | +isort --check-only --verbose ./pcpostprocess ./tests/ |
| 74 | +``` |
| 75 | + |
| 76 | +Isort is configured in [`pyproject.toml'](./pyproject.toml) under the section `tool.isort`. |
| 77 | + |
| 78 | +## Documentation |
| 79 | + |
| 80 | +[#60](https://github.com/CardiacModelling/pcpostprocess/issues/60) |
| 81 | + |
| 82 | +Every method and every class should have a [docstring](https://www.python.org/dev/peps/pep-0257/) that describes in plain terms what it does, and what the expected input and output is. |
| 83 | + |
| 84 | +Each docstring should start with a one-line explanation. |
| 85 | +If more explanation is needed, this one-liner is followed by a blank line and more information in the following paragraphs. |
| 86 | + |
| 87 | +TODO: SYNTAX, RUNNING LOCALLY, ETC |
| 88 | + |
| 89 | +TODO: EXAMPLES |
| 90 | + |
| 91 | +``` |
| 92 | +cd doc |
| 93 | +make clean |
| 94 | +make html |
| 95 | +``` |
| 96 | + |
| 97 | +[reStructuredText](http://docutils.sourceforge.net/docs/user/rst/quickref.html) |
| 98 | +[Sphinx](http://www.sphinx-doc.org/en/stable/) |
| 99 | + |
| 100 | +## Testing |
| 101 | + |
| 102 | +To run all unit tests, locally: |
| 103 | + |
| 104 | +``` |
| 105 | +$ python3 -m unittest |
| 106 | +``` |
| 107 | + |
| 108 | +To run a single test, use |
| 109 | +``` |
| 110 | +$ python3 -m unittest TestClass.test_method |
| 111 | +``` |
| 112 | + |
| 113 | +### Unit tests |
| 114 | + |
| 115 | +Testing is done with [unittest](https://docs.python.org/3.9/library/unittest.html). |
| 116 | + |
| 117 | +Each method in `pcpostprocess` should have a unit test. |
| 118 | + |
| 119 | +Tests should always aim to compare generated output with reference values, instead of just checking no errors are generated. |
| 120 | + |
| 121 | +### Coverage |
| 122 | + |
| 123 | +Coverage is checked with [coverage](https://coverage.readthedocs.io/en/7.11.3/). |
| 124 | + |
| 125 | +To run locally, use |
| 126 | +``` |
| 127 | +coverage run -m unittest |
| 128 | +``` |
| 129 | +and, if the tests pass, view the report with |
| 130 | +``` |
| 131 | +coverage report |
| 132 | +``` |
| 133 | + |
| 134 | +### Github actions |
| 135 | + |
| 136 | +Whenever changes are made to a branch with an open pull request, tests will be run using GitHub actions. |
| 137 | + |
| 138 | +These are configured in a single workflow TODO THIS IS BEING UPDATED ATM |
| 139 | + |
| 140 | +Coverage testing is run, and sent to [codecov.io](https://docs.codecov.io/docs) to generate [online reports](https://app.codecov.io/github/CardiacModelling/pcpostprocess). |
| 141 | + |
| 142 | +## Logging changes |
| 143 | + |
| 144 | +Each PR should add a line (or occasionally multiple lines) to [CHANGELOG.md](./CHANGELOG.md). |
| 145 | +This should be a very concise summary of the work done, and link to the PR itself for further info. |
| 146 | +Changes are classified as `Added`, `Changed`, `Deprecated`, `Removed`, or `Fixed`. |
| 147 | + |
| 148 | + |
| 149 | + |
| 150 | +## Packaging |
| 151 | + |
| 152 | +This project uses a minimal [`setup.py`](./setup.py), and instead uses [pyproject.toml](./pyproject.toml). |
| 153 | + |
| 154 | +### Versioning |
| 155 | + |
| 156 | +Version numbers are not set in the code, but derived from git tags, using [setuptools-scm](https://setuptools-scm.readthedocs.io/en/latest/). |
| 157 | +This is run every time setuptools is run, e.g. with |
| 158 | +``` |
| 159 | +pip install -e .[test] |
| 160 | +``` |
| 161 | + |
| 162 | +Versions numbers take the form `X.Y.Z` where X, Y, and Z are "major", "minor", and "revision" numbers. |
| 163 | +Changes to the public interface should be reflected in an updated minor version. |
| 164 | +Small changes should be indicated with revisions. |
| 165 | +These numbers don't stop at 9, so e.g. 1.11.12 is a viable number. |
| 166 | + |
| 167 | +**The version number is only changed when a new release is made** |
| 168 | + |
| 169 | +### Releases |
| 170 | + |
| 171 | +Releases, like other changes, are made on a branch, using the following procedure: |
| 172 | + |
| 173 | +1. Create a new branch. |
| 174 | +2. Update the changelog, replacing the "Unreleased" header with a version number and date, e.g. `## [0.2.0] - 2025-11-11`. |
| 175 | +3. Commit the change. |
| 176 | +4. Add a tag using e.g. `git tag v0.2.0`, and push it with `git push --tags`. |
| 177 | +5. Update the changelog, adding a new "Unreleased" header with empty categories. |
| 178 | +6. Merge the PR. |
| 179 | +7. [Add a new release](https://github.com/CardiacModelling/pcpostprocess/releases) in GitHub, using the tag you created, and copy in the changes from the changelog. |
| 180 | + |
| 181 | +TODO: THERE IS NO PACKAGING ON PYPI ATM |
| 182 | + |
| 183 | +### Licensing |
| 184 | + |
| 185 | +Licensing information is provided in a separate [LICENSE](./LICENSE) file. |
| 186 | + |
0 commit comments