|
| 1 | +How to Contribute to pyOptSparse |
| 2 | +================================ |
| 3 | +pyOptSparse is an open-source tool, thus we welcome users to submit additions or fixes to the code to make it better for everybody. |
| 4 | + |
| 5 | +Issues |
| 6 | +------ |
| 7 | +If you have an issue with pyOptSparse, a bug to report, or a feature to request, submit an issue on the GitHub repository. |
| 8 | +This lets other users know about the issue. |
| 9 | +If you are comfortable fixing the issue, please do so and submit a pull request. |
| 10 | + |
| 11 | +Coding style |
| 12 | +------------ |
| 13 | +We use `black <https://github.com/psf/black>`_ for formatting. |
| 14 | +Please install it following its documentation, and run it with the command line argument ``-l 120``, for example at the project root directory:: |
| 15 | + |
| 16 | + black . -l 120 |
| 17 | + |
| 18 | +This will automatically format all Python files. |
| 19 | + |
| 20 | +We use `flake8 <https://flake8.pycqa.org/en/latest/>`_ for linting. |
| 21 | +Please install it following its instructions, and run it at the project root with:: |
| 22 | + |
| 23 | + flake8 . |
| 24 | + |
| 25 | +which will use the ``.flake8`` configuration file provided by pyOptSparse. |
| 26 | + |
| 27 | +For an easier workflow, we recommend integrating these tools with your code editor. |
| 28 | + |
| 29 | +.. warning:: |
| 30 | + For a PR to be accepted, it must pass all GitHub checks, which include both formatting checks with ``black`` and syntax checks with ``flake8``. |
| 31 | + |
| 32 | +Documentation |
| 33 | +------------- |
| 34 | +When you add or modify code, make sure to provide relevant documentation that explains the new code. |
| 35 | +This should be done in code via docstrings and comments, but also in the Sphinx documentation as well if you add a new feature or capability. |
| 36 | +Look at the ``.rst`` files in the ``doc`` section of the repo. |
| 37 | + |
| 38 | +Testing |
| 39 | +------- |
| 40 | +When you add code or functionality, add tests that cover the new or modified code. |
| 41 | +These may be units tests for individual components or regression tests for entire models that use the new functionality. |
| 42 | +All the existing tests can be found under the ``test`` folder. |
| 43 | + |
| 44 | +Pull requests |
| 45 | +------------- |
| 46 | +Finally, after adding or modifying code, and making sure the steps above are followed, submit a pull request via the GitHub interface. |
| 47 | +This will automatically go through all of the tests in the repo to make sure everything is functioning properly. |
| 48 | +The main developers of pyOptSparse will then merge in the request or provide feedback on how to improve the contribution. |
0 commit comments