Contributing Guidelines#
Thank you for contributing to this project! We follow strict coding standards to ensure code quality and maintainability. Please follow these guidelines when submitting code:
Coding Standards#
PEP8 Compliance
Line Length
The maximum line length is 80 characters.
Naming Conventions
Follow standard naming conventions:
Variables:
snake_case
Classes:
CamelCase
Constants:
ALL_CAPS
Type Hints
All functions should have type hints for their input parameters.
Type hints for return values are not required (optional).
Example:
def add(x: int, y: int) -> int: return x + y
Interface Functions:
Functions without an underscore at the beginning of their name (e.g.,
loss
) are considered interface functions. These are the public-facing functions that users will import and interact with.These functions should have clear, concise docstrings, using the numpydoc format (see Documentation section below).
Non-Interface Functions
Functions that start with an underscore (e.g.,
_sample_loss
) are considered non-interface or internal functions. These are not meant to be directly accessed by the user.These functions still require proper type hints and concise commenting for internal logic, but a comprehensive docstrings is not required.
Documentation#
Use reStructuredText (
.rst
files) for documentation and README files.Docstrings
Interface functions and classes must include docstrings.
Non-interface functions are not required to have docstring.
Use the numpydoc format for all docstrings.
def add(x: int, y: int) -> int: """ Add two integers. Parameters ---------- x : int First number to add. y : int Second number to add. Returns ------- z : int The sum of `x` and `y`. """ return x + y
Build Sphinx Documentation
Upon adding new class/module, include the corresponding class/module name to the documentation in
/docs/source/api.rst
.Build the Sphinx documentation with:
cd /docs make clean html
You can view the documentation at
/docs/build/html/index.html
.
Tests#
Package Structure#
Adding a New Model
To add a new model, such as as a model named
foo_bar
:Create a new file in
/freealg
.Define a class therein called
FooBar
that is inherited fromBaseModel
base class.In
/freealg/__init__.py
import your new class and add its name to__all__
variable.