Minimalist And Customisable Optimisation Package
Thank you for taking the time to read this guide for the package's contribution. I'm glad to know that you may bring a lot to the Macop package. This document will show you the good development practices used in the project and how you can easily participate in its evolution!
2.1. Python conventions
2.3. Code documentation
2.2. Test implementation
3.1. Build package
3.2. Pull request
This project uses the naming conventions of the git branches set up by the git-flow interface. To make your contribution as easy as possible to inject into the project, you will need to name your git branch as follows:
git branch feature/YourFeatureBranchName
Using git-flow interface:
git flow feature start YourFeatureBranchName
As you perhaps already saw, package contains multiples modules and submodules. It's really import to be well organized package and let it intuitive to access as possible to features.
For the moment there are no precise conventions on the naming of new modules or sub-modules, it must just in a first step respect the hierarchy already in place and avoid any redundancies.
In order to facilitate the integration of new modules, do not hesitate to let me know the name it could have beforehand.
This project follows the coding conventions implemented by Google. To help you to format *.py files, it is possible to use the yapf package developed by Google.
Note that the yapf package is used during build process of macop package to format the whole code following these conventions.
In order to allow quick access to the code, the project follows the documentation conventions (docstring) proposed by Google. Here an example:
''' Binary integer solution class
- store solution as a binary array (example: [0, 1, 0, 1, 1])
- associated size is the size of the array
- mainly use for selecting or not an element in a list of valuable objects
Attributes:
data: {ndarray} -- array of binary values
size: {int} -- size of binary array values
score: {float} -- fitness score value
'''
You can generate documentation and display updates using these following commands:
bash build.sh
firefox docs/index.html
Do not forget to generate new documentation output before doing a pull request.
This project use the doctest package which enables to write tests into documentation as shown in example below:
""" Initialise binary solution using specific data
Args:
data: {ndarray} -- array of binary values
size: {int} -- size of binary array values
Example:
>>> from macop.solutions.discrete import BinarySolution
>>> # build of a solution using specific data and size
>>> data = [0, 1, 0, 1, 1]
>>> solution = BinarySolution(data, len(data))
>>> # check data content
>>> sum(solution._data) == 3
True
>>> # clone solution
>>> solution_copy = solution.clone()
>>> all(solution_copy._data == solution._data)
"""
Moreover, tests written are displayed into generated documentation and let examples of how to use the developed function.
One thing to do before submit your feature is to build the package:
python setup.py build
This command do a lot of thing for you:
Do not forget to build documentation as explained in section 2.3.
Or directly use bash script which runs all you need:
bash build.sh
Once you have built the package following previous instructions. You can make a pull request using GitHub. A documentation about pull requests is available.
To enhance the package, do not hesitate to report bug or missing feature. To do that, just submit an issue using at one of this labels:
You can also add your own labels too or add priority label:
Main common required issue header:
Package version: X.X.X
Issue label: XXXXX
Priority: prio:**level**
Targeted modules: `macop.algorithms`, `macop.policies`
Operating System: Manjaro Linux
Description: XXXXX
Whatever the problem reported, I will thank you for your contribution to this project. So do not hesitate.