As part of the software sustainability hackathon, efforts are ongoing to make CIL easier to use for users and developers.
This issue is focused on improving the python code documentation with Numpy-style docstrings, modern python typehinting, and following a standard format for class structure.
If the function has typehints, omit type hinting from the docstring:
def __init__(self, input:AcquisitionData, image_geometry:Optional[ImageGeometry]=None, backend="tigre"):
"""Abstract class for a tomographic reconstructor.
Parameters
----------
input
Input data for reconstruction
image_geometry
Image geometry of input data, by default None
backend
Engine backend used for reconstruction, by default "tigre"
Raises
------
TypeError
Raised if input data is not an AcquisitionData class
"""
Private functions do not need to be documented (they are for developer internal use)
Class Structure (basically an inverse of c):
__init__
Init is first due to its documentation existing in the class's docstring, and properties may be large
Properties
Static functions
Functions
Private functions
Special functions (__str__())
Use " for strings (May change later on, but uniformity is good)
Use relative imports from cil.framework.recon import Reconstructor -> from .Reconstructor import Reconstructor to fix circular packaging issues #1681
There are still ongoing talks for enforcing a code style with a formatter, as
such this issue ignores code style, and focuses on class order and doc comments.
Note: this change doesn't include functional changes that have been discussed:
Functions should return out if passed in, not None #1657
As part of the software sustainability hackathon, efforts are ongoing to make CIL easier to use for users and developers.
This issue is focused on improving the python code documentation with Numpy-style docstrings, modern python typehinting, and following a standard format for class structure.
'Standards' followed:
Using Numpy's doc format for python
If the function has typehints, omit type hinting from the docstring:
__init__
__str__()
)"
for strings (May change later on, but uniformity is good)from cil.framework.recon import Reconstructor
->from .Reconstructor import Reconstructor
to fix circular packaging issues #1681There are still ongoing talks for enforcing a code style with a formatter, as such this issue ignores code style, and focuses on class order and doc comments.
Note: this change doesn't include functional changes that have been discussed:
out
if passed in, notNone
#1657Progress:
cil/