CONTRIBUTING 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. How to contribute
  2. =====================================
  3. <p align="center">
  4. <img src="https://github.com/jbuisine/macop/blob/master/docs/source/_static/logo_macop.png" alt="" width="40%">
  5. </p>
  6. # Welcome !
  7. 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!
  8. # Table of contents
  9. 1. [Submission processes](#submission-process)
  10. 1.2. [Submit an issue](#submit-an-issue)
  11. 1.1. [Pull request](#pull-request)
  12. 2. [Coding conventions](#coding-conventions)
  13. 2.1. [Python conventions](#python-conventions)
  14. 2.2. [Code documentation](#code-documentation)
  15. 2.3. [Testing](#test-implementation)
  16. # Submission process
  17. ## Submit an issue
  18. Do not hesitate to report bug or issue in [https://github.com/jbuisine/macop/issues](https://github.com/jbuisine/macop/issues) with the common template header:
  19. ```
  20. **Package version:** X.X.X
  21. **Issue label:** XXXXX
  22. **Targeted modules:** `macop.algorithms`, `macop.policies`
  23. **Operating System:** Manjaro Linux
  24. **Description:** XXXXX
  25. ```
  26. ## Pull request
  27. If you have made changes to the project you have forked, you can submit a pull request in [https://github.com/jbuisine/macop/pulls](https://github.com/jbuisine/macop/pulls) in order to have your changes added inside new version of the `Macop` package. A [GitHub documentation](https://help.github.com/articles/about-pull-requests/) about pull requests is available if necessary.
  28. 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:
  29. ```
  30. **Package version:** X.X.X
  31. **Enhancements label:** XXXXX
  32. **Targeted modules:** `macop.algorithms`, `macop.policies`
  33. **New modules:** `macop.XXXX`, `macop.algorithms.XXXX`
  34. **Description:** XXXXX
  35. ```
  36. **Note:** the code conventions required for the approval of your changes are described below.
  37. Whatever the problem reported, I will thank you for your contribution to this project. So do not hesitate.
  38. # Coding conventions
  39. ## Python conventions
  40. This project follows the [coding conventions](http://google.github.io/styleguide/pyguide.html) implemented by Google. To help you to format **\*.py** files, it is possible to use the [yapf](https://github.com/google/yapf/) Python package developed by Google.
  41. ```
  42. yapf -ir -vv macop
  43. ```
  44. **Note:** you need at least Python version >=3.7.0.
  45. ## Package modules conventions
  46. 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.
  47. `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](https://jbuisine.github.io/macop) if necessary.
  48. 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.
  49. ## Code documentation
  50. In order to allow quick access to the code, the project follows the documentation conventions (docstring) proposed by Google. Here an example:
  51. ```python
  52. ''' Binary integer solution class
  53. - store solution as a binary array (example: [0, 1, 0, 1, 1])
  54. - associated size is the size of the array
  55. - mainly use for selecting or not an element in a list of valuable objects
  56. Attributes:
  57. data: {ndarray} -- array of binary values
  58. size: {int} -- size of binary array values
  59. score: {float} -- fitness score value
  60. '''
  61. ```
  62. You can generate documentation and display updates using these following commands:
  63. ```
  64. bash build.sh
  65. firefox docs/build/index.html
  66. ```
  67. ## Test implementation
  68. This project uses the [doctest](https://docs.python.org/3/library/doctest.html) package which enables to write tests into documentation as shown in example below:
  69. ```python
  70. """ Initialise binary solution using specific data
  71. Args:
  72. data: {ndarray} -- array of binary values
  73. size: {int} -- size of binary array values
  74. Example:
  75. >>> from macop.solutions.discrete import BinarySolution
  76. >>> # build of a solution using specific data and size
  77. >>> data = [0, 1, 0, 1, 1]
  78. >>> solution = BinarySolution(data, len(data))
  79. >>> # check data content
  80. >>> sum(solution._data) == 3
  81. True
  82. >>> # clone solution
  83. >>> solution_copy = solution.clone()
  84. >>> all(solution_copy._data == solution._data)
  85. """
  86. ```
  87. Moreover, tests written are displayed into generated documentation and show examples of how to use the developed features.