![]() |
COMPASS
5.4.4
End-to-end AO simulation tool using GPU acceleration
|
Basicaly, it can be summarized like this:
For example:
All names must be explicit.
For example, applyVoltGetSlopes
instead of apply_volt_and_get_slopes
This convention is also the baseline for the C++ API.
More info about PEP8 and Google C++ Style Guide
All the variables declared in the code must have an explicit name which is coherent with its assignation. Then :
All the attributes of a class must be declared in its init method. If it is assigned by an other method, declares it as None in the init method.
If a method/function use keyword arguments, force to use explicitly each keyword when a call is made. Python 3 allows to do it easily using *
:
With this convention, calling my_favorite_function(0, 1)
will result in an error as the code expects only one positional argument. Then, the correct way to call this function is my_favorite_function(0, kwarg_1=1)
, and this is much more explicit and easy to read and understand.
Exception can be made for method/function using only one keyword argument without any positional argument :
All the class and method must be documented following a doxypypy compatible format. In the class documentation, attributes of the class must be listed and described :
In the method documentation, follow the docstring template below:
The typing python module must be used to also described the variable and return type in function signature, as in the example above. Respect the docstring template described above, including attention to alinea, line break between parameters...
As COMPASS had become quite huge with time, code documentation will be a long term objective which will require contributions from everyone : do not hesitate to reformat, complete or modify docstrings that do not respect the above rules. We are counting on you all...
For Visual Studio code users, we recommends to use Doxygen Documentation Generator. It really useful, it will generate a template based on the function signature.
The develop branch is protected, which means that you cannot push on it directly. The typical process is as follows:
When you are satisfied with your changes, in the message, it offers to make a merge request on develop of the style:
If you have already committed to develop, you will not be able to push them on gitlab. To avoid losing your changes in progress:
then make your merge request as defined above
If you use COMPASS to publish, please cite one of those reference: