Skip to content

Commit

Permalink
enhance docstring
Browse files Browse the repository at this point in the history
Signed-off-by: YunLiu <[email protected]>
  • Loading branch information
KumoLiu committed Jan 24, 2025
1 parent 83c4729 commit 10d89ad
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
27 changes: 21 additions & 6 deletions monai/transforms/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,13 @@ def execute_compose(
Args:
data: a tensor-like object to be transformed
transforms: a sequence of transforms to be carried out
map_items: whether to apply transform to each item in the input `data` if `data` is a list or tuple.
defaults to `True`. If set to an integer, recursively map the items in `data` `map_items` times.
map_items: controls whether to apply a transformation to each item in `data`. If `data` is a list or tuple,
it can behave as follows:
- Defaults to True, which is equivalent to `map_items=1`, meaning the transformation will be applied
to the first level of items in `data`.
- If an integer is provided, it specifies the maximum level of nesting to which the transformation
should be recursively applied. This allows treating multi-sample transforms applied after another
multi-sample transform while controlling how deep the mapping goes.
unpack_items: whether to unpack input `data` with `*` as parameters for the callable function of transform.
defaults to `False`.
start: the index of the first transform to be executed. If not set, this defaults to 0
Expand Down Expand Up @@ -205,8 +210,13 @@ class Compose(Randomizable, InvertibleTransform, LazyTransform):
Args:
transforms: sequence of callables.
map_items: whether to apply transform to each item in the input `data` if `data` is a list or tuple.
defaults to `True`. If set to an integer, recursively map the items in `data` `map_items` times.
map_items: controls whether to apply a transformation to each item in `data`. If `data` is a list or tuple,
it can behave as follows:
- Defaults to True, which is equivalent to `map_items=1`, meaning the transformation will be applied
to the first level of items in `data`.
- If an integer is provided, it specifies the maximum level of nesting to which the transformation
should be recursively applied. This allows treating multi-sample transforms applied after another
multi-sample transform while controlling how deep the mapping goes.
unpack_items: whether to unpack input `data` with `*` as parameters for the callable function of transform.
defaults to `False`.
log_stats: this optional parameter allows you to specify a logger by name for logging of pipeline execution.
Expand Down Expand Up @@ -391,8 +401,13 @@ class OneOf(Compose):
transforms: sequence of callables.
weights: probabilities corresponding to each callable in transforms.
Probabilities are normalized to sum to one.
map_items: whether to apply transform to each item in the input `data` if `data` is a list or tuple.
defaults to `True`. If set to an integer, recursively map the items in `data` `map_items` times.
map_items: controls whether to apply a transformation to each item in `data`. If `data` is a list or tuple,
it can behave as follows:
- Defaults to True, which is equivalent to `map_items=1`, meaning the transformation will be applied
to the first level of items in `data`.
- If an integer is provided, it specifies the maximum level of nesting to which the transformation
should be recursively applied. This allows treating multi-sample transforms applied after another
multi-sample transform while controlling how deep the mapping goes.
unpack_items: whether to unpack input `data` with `*` as parameters for the callable function of transform.
defaults to `False`.
log_stats: this optional parameter allows you to specify a logger by name for logging of pipeline execution.
Expand Down
5 changes: 1 addition & 4 deletions monai/transforms/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ def apply_transform(
Args:
transform: a callable to be used to transform `data`.
data: an object to be transformed.
map_items: whether to apply transform to each item in `data`,
if `data` is a list or tuple. Defaults to True.
it can also be an int, if so, recursively map the items in `data` `map_items` times.
map_items: Controls whether to apply a transformation to each item in `data`. If `data` is a list or tuple,
map_items: controls whether to apply a transformation to each item in `data`. If `data` is a list or tuple,
it can behave as follows:
- Defaults to True, which is equivalent to `map_items=1`, meaning the transformation will be applied
to the first level of items in `data`.
Expand Down

0 comments on commit 10d89ad

Please sign in to comment.