This page contains an overview of instructions for people intending to develop PyPO
. These include the contributor guidelines, but also guidelines on how to document contributions and how to test PyPO
.
People wishing to contribute are more than welcome to do so. Contributions can be made by opening a pull request to the main repository from your own fork of PyPO
. This is the so-called fork-and-branch workflow. Create a fork from the PyPO repository to your own profile, and clone:
Set the original repo as upstream:
It is good practice to make a feature branch in which you can store your work:
Then, when it is time to push the changes to the original repo, run:
This should prompt Github to ask you to open a pull request to the orignial repository. Open the pull request, and the contribution will be reviewed. If it is accepted, the changes will be merged into the original main branch. After the merge, do not forget to synchronise your remote/local copy:
Then, the feature branch can be deleted:
Issues, feature requests and bugs can be reported in the PyPO
issue tracker. In addition to the online issue tracker in the git repo, we maintain a list of commonly encountered issues for quick reference.
As mentioned in the contributor guidelines, contributions to PyPO
are more than welcome. This section contains information on utilities put in place to make it easier to develop, as well as certain rules and practices for making PyPO
easy to maintain.
It is assumed that you have forked the PyPO repository to a root directory, which we will call PyPO-dev for now.
Installing PyPO
for development is very similar to general installation: Navigate to the cloned (and forked) PyPO repository and run:
The "-e" flag tells pip to install PyPO
in the actual "src/PyPO/" directory of the PyPO
repository. This means that any changes to the Python source code are immediately reflected in the package imported through Python. For the C/C++/CUDA code, this is not true. These scripts need to be compiled into libraries again (which happens when the pip install -e .
command is run) before the changes are reflected in the package.
PyPO can be uninstalled by running:
Note that this does not remove the compiled libraries in the "src/PyPO/" folder. If desired, these need to be removed manually.
PyPO
documentation is generated using Doxygen and generated from comment blocks. Because of this, there are several rules for developers regarding comments.
The C/C++/CUDA scripts use the so-called Javadoc style for documenting classes and methods:
In addition to properly documented classes and methods, each file should include a file description with an appropriate tag, so that doxygen can include the file in the full software documentation. The file description should be given after includes/preprocessor statements, but before the first class or method is declared:
The Python classes and methods are documented using docstrings with a slight twist, as Doxygen's special commands are not supported using pure docstrings. The trick to making doxygens special commands work with docstrings, is placing an exclamation mark right after the first triple double quotes:
The exclamation mark tells doxygen to parse the docstring as a doxygen documentation block. This allows doxygen to generate documentation, while also allowing the built-in help()
function of Python to recognise the docstring, albeit with a lone "!" prepending the output of help()
.
File descriptions go on the top of the file:
Again, adding these file descriptions is important, otherwise the file will not be parsed and added to the full software documentation. Tests are also supposed to carry a file description, but the test functions do not need a full documentation.
The "Templates.py" file containing templates for all used dictionary inputs is documented in the following style:
It is important to add the @ingroup public_api_templates
command to the documentation block, as this puts the documentation on the right page in the final HTML output. Also, if you add a new input dictionary type, please document the meaning of each field in the demonstrated way.
For an overview of the mentioned (and other) comment styles for doxygen, see this link.
The documentation can be generated using the GenerateDocs.py
script:
This will generate the full PyPO
user manual and place it in the "docs/" directory. Note that this requires a full doxygen install. Please see their installation page for installation instructions.
PyPO
contains an automated testing suite that can be run quite easily from the command line using nose2. Note that, in order to run the unit tests, PyPO
should be installed in development mode.
Navigate to the PyPO
root directory and run:
This command will execute the entire testing suite.
Note that nose2 needs to be installed for this:
Apart from running the test suite, it is also possible to generate a coverage report afterwards. For this, coverage needs to be installed in addition to nose2:
The coverage report can then be generated by running:
and the coverage report will be displayed in the terminal after running the tests.
If desired, further coverage info can be obtained by running:
in the PyPO
root directory. Then, in-depth coverage information can be viewed by running the index.html
file in the htmlconv/
folder in the PyPO
root directory.
A small suite of unittests for the C/C++/CUDA backend is also present and is tested using googletest. These tests are mostly testing the vector operations, but might be extended as PyPO
keeps developing. If you intend to work on the backend, it might be a good thing to be able to run these tests. Please see the installation instructions for building googletest on your specific platform.
After installing googletest, the tests need to be built. Navigate to the src/
folder and run:
which should generate build scripts, make them and run the unittests in one go. For more options for the SetupGTest.py
script, run:
Note that most backend functionality is implicitly tested through the (larger) Python unittesting suite, and if not developing in the C/C++/CUDA backend, the Python unittesting suite should be sufficient to test correct functioning of PyPO
.