Skip to content

Coding Style

Akshay Subramaniam edited this page Jun 28, 2017 · 20 revisions

Programming language

We use Python 2 as the programming language for the core modules.

Naming convection

It is recommended to use:

  1. UpperCamelCase for class names
  2. lowerCamelCase for methods and functions
  3. CAPITALIZED_WITH_UNDERSCORES for constants
  4. lowercase_separated_by_underscores for variable names
  5. lowercase_separated_by_underscores for python file names
  6. UpperCamelCase for names of Jupyter Notebook test scripts

Indentation

4 spaces of indentation, and no tab characters should be used.

Comments

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.

Others

Use two empty lines between def's.

Testing

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)
Clone this wiki locally