Skip to content

Latest commit

 

History

History
166 lines (108 loc) · 5.61 KB

CONTRIBUTING.md

File metadata and controls

166 lines (108 loc) · 5.61 KB

How to contribute

Welcome !

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!

Table of contents

  1. Submission processes

    1.1. Submit an issue

    1.2. Pull request

    1.3. Seek support

  2. Coding conventions

    2.1. Python conventions

    2.2. Code documentation

    2.3. Testing

Submission process

Submit an issue

Do not hesitate to report bug or issue in https://github.com/jbuisine/macop/issues with the common template header:

**Package version:** X.X.X
**Issue label:** XXXXX
**Targeted modules:** `macop.algorithms`, `macop.policies`
**Operating System:** Manjaro Linux

**Description:** XXXXX

Pull request

If you have made changes to the project you have forked, you can submit a pull request in https://github.com/jbuisine/macop/pulls in order to have your changes added inside new version of the Macop package. A GitHub documentation about pull requests is available if necessary.

To enhance the package, do not hesitate to fix bug or missing feature. To do that, just submit your pull request with this common template header:

**Package version:** X.X.X
**Enhancements label:** XXXXX
**Targeted modules:** `macop.algorithms`, `macop.policies`
**New modules:** `macop.XXXX`, `macop.algorithms.XXXX`

**Description:** XXXXX

Note: the code conventions required for the approval of your changes are described below.

Whatever the problem reported, I will thank you for your contribution to this project. So do not hesitate.

Seek support

If you have any problem with the use of the package, issue or pull request submission, do not hesitate to let a message to https://github.com/jbuisine/macop/discussions. Especially in the question and answer section.

You can also contact me at the following email address: contact@jeromebuisine.fr.

Coding conventions

Python conventions

This project follows the coding conventions implemented by Google. To help you to format *.py files, it is possible to use the yapf Python package developed by Google.

yapf -ir -vv macop

Note: you need at least Python version >=3.7.0.

Package modules conventions

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.

Macop is mainly decompose into discrete and continuous optimisation. Especially if you want to offer continuous optimisation problems, modules are already available for this purpose. You can refer to the documentation if necessary.

In order to facilitate the integration of new modules, do not hesitate to let me know the name it could have beforehand in your pull request.

Code documentation

In order to allow quick access to the code, the project follows the documentation conventions (docstring) proposed by Google. Here an example:

class BinarySolution():
"""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
"""

For method:

class BinarySolution():

...

def random(self, validator):
    """
    Intialize binary array with use of validator to generate valid random solution

    Args:
        size: {int} -- expected solution size to generate
        validator: {function} -- specific function which validates or not a solution (if None, not validation is applied)

    Returns:
        {:class:`~macop.solutions.discrete.BinarySolution`}: new generated binary solution
    """
    ...

You can generate documentation and display updates using these following commands:

cd docs
make clean && make html
firefox _build/html/index.html

Test implementation

This project uses 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 show examples of how to use the developed features.