Adding a new Python function¶
Great, you want to contribute a Python function or module to Nighres!
Before you begin¶
Take a moment to familiarise yourself with the documentation and functions, it is likely that some helper functions that you will want to use (e.g., I/O) have already been coded and tested.
Let’s get into it¶
Follow the steps described in Setting up
Decide where to put your code
If the functionality that you are adding falls within the scope of a pre-existing submodule, edit or create files within the submodule. If it is entirely new (e.g., statistics), create a new submodule with its own dedicated subdirectory.
Coding If you are creating a submodule from scratch, an easy way to start is to copy the __init.py__ and initial import statements from an existing module.
Please code PEP8 compliant, best to use a Python linter in your editor.
Please keep within our documentation guidelines.
Leave plenty of comments in your code so that others can understand and possibly adapt your code later.
Use the standard I/O interfaces wherever possible but also fee free to add additional I/O functionality as necessary.
Test you code internally. We aim to add unittests in the future, feel free to make a start on that.
Write an example showcasing your new function
Pat yourself on the back, you have now joined the Nighres developer community!
A word on dependencies
One of Python’s strengths are the many different packages with specific functionalities. We try to keep the dependencies for Nighres as slim as possible, so please keep that in mind while you are coding. For example, if you need to perform a correlation and would normally use scipy.stats.pearsonr maybe you can get by with numpy.coeff (numpy is already a dependency, scipy isn’t). If additional packages are required, they should be pip installable and potentially relevant to other functionality that may be coded in the future.