Contributing¶
dev
branch.Note
Do not create pull requests into the master
branch. Pull requests should be made to the dev
branch, from which changes will be merged into master
on releases.
Code and Documentation¶
Comments - Even if the code is clear, use comments to explain steps (step comment example).
Variable verbosity - Use verbose variable names that imply the meaning of their content, e.g. use
mask
instead ofm
.Clear tensor shapes - When applying operations on tensors, include the shape of the result in a comment. (tensor shape example).
Format - reStructuredText is the documentation format use, and specifically PEP 287 (PyCharm’s default) for class methods. On class level docstring, make sure you always include the following sections:
Arguments - For the
__init__
arguments (Arguments section example).Examples - For examples (Examples section example)
References - For sources (articles etc.) for further reading (References section example).
If you are contributing a
tf.keras.layers.Layer
subclass, also include:
Input Shape - Input shape accepted by the layer’s
call
method (Input Shape section example).Output Shape - Output shape accepted by the layer’s
call
method (Output Shape section example).
Testing¶
tests/<parent_module>/<module_name>_test.py
.tvl.normalization.LayerNormalization
, the tests should be written in tests/normalization/layer_normalization_test.py
.tf.keras.layers.Layer
implementation, always include:
test_shapes()
- Given accepted input shapes, make sure the output shape is as expected (test_shapes() example).
test_masking()
- Make sure layer supports masking (test_masking() example).
test_serialization()
- Make sure layer can be saved and loaded usingget_config
andfrom_config
(test_serialization() example).
test_logic()
for evaluating expected output given known input (test_logic() example).pytest --cov=tavolo tests/
dev
branch) and it will be added to the package in a following release.