Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update doc comments, typehinting, and code structure #1683

Open
11 tasks
WYVERN2742 opened this issue Feb 8, 2024 · 1 comment
Open
11 tasks

Update doc comments, typehinting, and code structure #1683

WYVERN2742 opened this issue Feb 8, 2024 · 1 comment
Assignees
Milestone

Comments

@WYVERN2742
Copy link

WYVERN2742 commented Feb 8, 2024

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:
       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):
    1. __init__
      • Init is first due to its documentation existing in the class's docstring, and properties may be large
    2. Properties
    3. Static functions
    4. Functions
    5. Private functions
    6. 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 Remove Reconstructor from __init__ to prevent circular dependency #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:


Progress:

cil/

@WYVERN2742
Copy link
Author

Note: This does depend on #1686 to be merged, and then another pass to ensure typing compatabillity across CIL to finally pass static checkers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: No status
Development

No branches or pull requests

3 participants