Skip to content

Commit

Permalink
improve docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
Czaki committed Oct 17, 2024
1 parent 3aacae8 commit 86d423e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions package/PartSeg/_roi_mask/stack_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ def transform_state(
:param MaskProjectTuple state: state to be transformed
:param ROIInfo new_roi_info: roi description
:param typing.Dict[int, typing.Optional[ROIExtractionProfile]] new_roi_extraction_parameters:
:param dict[int, typing.Optional[ROIExtractionProfile]] new_roi_extraction_parameters:
Parameters used to extract roi
:param typing.List[int] list_of_components: list of components from new_roi which should be selected
:param list[int] list_of_components: list of components from new_roi which should be selected
:param bool save_chosen: if save currently selected components
:return: new state
"""
Expand Down
9 changes: 5 additions & 4 deletions package/PartSegCore/algorithm_describe_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import typing
import warnings
from abc import ABC, ABCMeta, abstractmethod
from collections.abc import MutableMapping
from functools import wraps
from importlib.metadata import version
from typing import Annotated
Expand Down Expand Up @@ -535,13 +536,13 @@ def pretty_print(self, algorithm_dict):
)

@classmethod
def _pretty_print(cls, values: typing.MutableMapping, translate_dict: dict[str, AlgorithmProperty], indent=0):
if not isinstance(values, typing.MutableMapping):
def _pretty_print(cls, values: MutableMapping, translate_dict: dict[str, AlgorithmProperty], indent=0):
if not isinstance(values, MutableMapping):
return textwrap.indent(str(values), " " * indent)
res = ""
for k, v in values.items():
if k not in translate_dict:
if isinstance(v, typing.MutableMapping):
if isinstance(v, MutableMapping):
res += " " * indent + f"{k}: {cls._pretty_print(v, {}, indent + 2)}\n"
else:
res += " " * indent + f"{k}: {v}\n"
Expand All @@ -561,7 +562,7 @@ def _pretty_print(cls, values: typing.MutableMapping, translate_dict: dict[str,
if values_:
res += "\n"
res += cls._pretty_print(values_, desc.possible_values[name].get_fields_dict(), indent + 2)
elif isinstance(v, typing.MutableMapping):
elif isinstance(v, MutableMapping):
res += cls._pretty_print(v, {}, indent + 2)
else:
res += str(v)
Expand Down
2 changes: 1 addition & 1 deletion package/PartSegCore/analysis/calculation_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ class Calculation(BaseCalculation):
:ivar CalculationPlan ~.calculation_plan: plan of calculation
:ivar str uuid: ~.uuid of whole calculation
:ivar ~.voxel_size: default voxel size (for files which do not contains this information in metadata
:ivar typing.List[str] ~.file_list: list of files to be proceed
:ivar list[str] ~.file_list: list of files to be proceed
"""

def __init__(
Expand Down
5 changes: 1 addition & 4 deletions package/PartSegCore/analysis/measurement_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def get_channel_num(self, measurement_dict: dict[str, "MeasurementMethodBase"])
"""
Get set with number of channels needed for calculate this measurement
:param measurement_dict: dict with all measurementh method.
:param measurement_dict: dict with all measurement methods.
:return: set of channels num
"""
resp = set()
Expand Down Expand Up @@ -380,9 +380,6 @@ def calculate_property(
Main function for calculating measurement
:param channel: main channel selected for measurement
:param channel_{i}: for channel requested using :py:meth:`get_fields`
``AlgorithmProperty("channel", "Channel", 0, value_type=Channel)``
:param area_array: array representing current area returned by :py:meth:`area_type`
:param roi: array representing roi
:param mask: array representing mask (upper level roi)
:param voxel_size: size of single voxel in meters
Expand Down
6 changes: 3 additions & 3 deletions package/PartSegCore/mask/io_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ class MaskProjectTuple(ProjectInfoBase):
:ivar typing.Optional[np.ndarray] ~.mask: Mask limiting segmentation area.
:ivar ROIInfo ~.roi_info: ROI information.
:ivar SegmentationInfo ~.roi_info: ROI description
:ivar typing.List[int] ~.selected_components: list of selected components
:ivar typing.Dict[int,typing.Optional[SegmentationProfile]] ~.segmentation_parameters:
:ivar list[int] ~.selected_components: list of selected components
:ivar dict[int,typing.Optional[SegmentationProfile]] ~.segmentation_parameters:
For each component description set of parameters used for segmentation
:ivar typing.List[HistoryElement] history: list of operations needed to create :py:attr:`mask`
:ivar list[HistoryElement] history: list of operations needed to create :py:attr:`mask`
:ivar str ~.errors: information about problems meet during calculation
:ivar typing.Optional[typing.List[float]] ~.spacing: information about spacing when image is missed.
For napari read plugin
Expand Down
2 changes: 1 addition & 1 deletion package/PartSegCore/mask_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def calculate_mask(
:param typing.Optional[np.ndarray] old_mask: if in mask_description there is set to crop and old_mask is not None
then final mask is clipped to this area
:param typing.Iterable[typing.Union[float,int]] spacing: spacing of image. Needed for calculating radius of dilate
:param typing.Optional[typing.List[int]] components: If present inform which components
:param typing.Optional[list[int]] components: If present inform which components
should be used when calculation mask, otherwise use all.
:param typing.Optional[int] time_axis: which axis of array should be treated as time. IF none then none.
:return: new mask
Expand Down

0 comments on commit 86d423e

Please sign in to comment.