Programer’s manual

Itzï is written principaly in Python. The computationally intensive parts of the code and some C bindings are written in Cython. Itzï includes the SWMM source code, which is written in C. As of version 20.5, itzi only supports Python 3.

We do our best to keep Itzï PEP8-compliant. Please use the pycodestyle utility to check your code for compliance. Sometimes it is difficult to keep the line length under 72 characters. The line length could be extended to 90 characters in those cases.

Source code management

The source code is managed by git and hosted on Bitbucket. The best way to contribute is to fork the main repository, make your modifications and then create a pull request on Bitbucket. The repository have two branches:

  • master than contain the current released verion.
  • dev where the main development takes place.

The code should be tested in dev before being merged to master for release.

Development environment

We recommend to create a virtual environment to work on the source code.

$ python3 -m venv itzi_dev

Then you can activate the virtual env and install the dev version of Itzï.

$ source itzi_dev/bin/activate
$ pip install numpy
$ cd itzi
$ pip install -e .

Now, every change you make to the Python code will be directly reflected when running itzi from the command line. To leave the virtual env:

$ deactivate

Cython code

After modifying the Cython code, you should first compile it to C, then compile the C code.

$ cython -3 itzi/swmm/swmm_c.pyx itzi/flow.pyx
$ rm -rf build/
$ pip install -e .

Testing

Testing is done through pytest. Running the tests require the following additional requirements:

  • pytest
  • pytest-cov
  • pytest-xdist
  • pandas
  • requests

pytest-xdist allows to run each test in a separate process. To do so, run the following command:

$ pytest --forked -v

To estimate the test coverage:

$ pytest --cov=itzi --forked -v

Packaging

The process for packaging and sending to pypi is done via a bitbucket pipeline, defined in the bitbucket-pipelines.yml file.