-
Notifications
You must be signed in to change notification settings - Fork 19
Coding Style
Akshay Subramaniam edited this page Jun 28, 2017
·
20 revisions
We use Python 2 as the programming language for the core modules.
It is recommended to use:
-
UpperCamelCase
for class names -
lowerCamelCase
for methods and functions -
CAPITALIZED_WITH_UNDERSCORES
for constants -
lowercase_separated_by_underscores
for variable names -
lowercase_separated_by_underscores
for python file names -
UpperCamelCase
for names of Jupyter Notebook test scripts
4 spaces of indentation, and no tab characters should be used.
Triple quote format is preferred for docstring that appears as first statement in classes, methods or functions.
A single line above the code is recommended. Add full stop at the end of each comment.
Use two empty lines between def
's.
For every module module_name.py
, write a corresponding test class TestModuleName
in a tests/test_module_name.py
file using the unittest
package. This then allows automated testing using python -m unittest discover -s floatpy/tests -v
from the project directory
- Write one test file for each module you write
- Use long and descriptive names for each test
- Try not to make tests that take a long time to run
- If data is needed for your test, put it in
tests/test_module_name_data/
- Make sure the data for your test is small (< 1MB in total)
- User Guide
- Tutorials