Skip to content

Commit 10d89ad

Browse files
committed
enhance docstring
Signed-off-by: YunLiu <[email protected]>
1 parent 83c4729 commit 10d89ad

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

monai/transforms/compose.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,13 @@ def execute_compose(
6565
Args:
6666
data: a tensor-like object to be transformed
6767
transforms: a sequence of transforms to be carried out
68-
map_items: whether to apply transform to each item in the input `data` if `data` is a list or tuple.
69-
defaults to `True`. If set to an integer, recursively map the items in `data` `map_items` times.
68+
map_items: controls whether to apply a transformation to each item in `data`. If `data` is a list or tuple,
69+
it can behave as follows:
70+
- Defaults to True, which is equivalent to `map_items=1`, meaning the transformation will be applied
71+
to the first level of items in `data`.
72+
- If an integer is provided, it specifies the maximum level of nesting to which the transformation
73+
should be recursively applied. This allows treating multi-sample transforms applied after another
74+
multi-sample transform while controlling how deep the mapping goes.
7075
unpack_items: whether to unpack input `data` with `*` as parameters for the callable function of transform.
7176
defaults to `False`.
7277
start: the index of the first transform to be executed. If not set, this defaults to 0
@@ -205,8 +210,13 @@ class Compose(Randomizable, InvertibleTransform, LazyTransform):
205210
206211
Args:
207212
transforms: sequence of callables.
208-
map_items: whether to apply transform to each item in the input `data` if `data` is a list or tuple.
209-
defaults to `True`. If set to an integer, recursively map the items in `data` `map_items` times.
213+
map_items: controls whether to apply a transformation to each item in `data`. If `data` is a list or tuple,
214+
it can behave as follows:
215+
- Defaults to True, which is equivalent to `map_items=1`, meaning the transformation will be applied
216+
to the first level of items in `data`.
217+
- If an integer is provided, it specifies the maximum level of nesting to which the transformation
218+
should be recursively applied. This allows treating multi-sample transforms applied after another
219+
multi-sample transform while controlling how deep the mapping goes.
210220
unpack_items: whether to unpack input `data` with `*` as parameters for the callable function of transform.
211221
defaults to `False`.
212222
log_stats: this optional parameter allows you to specify a logger by name for logging of pipeline execution.
@@ -391,8 +401,13 @@ class OneOf(Compose):
391401
transforms: sequence of callables.
392402
weights: probabilities corresponding to each callable in transforms.
393403
Probabilities are normalized to sum to one.
394-
map_items: whether to apply transform to each item in the input `data` if `data` is a list or tuple.
395-
defaults to `True`. If set to an integer, recursively map the items in `data` `map_items` times.
404+
map_items: controls whether to apply a transformation to each item in `data`. If `data` is a list or tuple,
405+
it can behave as follows:
406+
- Defaults to True, which is equivalent to `map_items=1`, meaning the transformation will be applied
407+
to the first level of items in `data`.
408+
- If an integer is provided, it specifies the maximum level of nesting to which the transformation
409+
should be recursively applied. This allows treating multi-sample transforms applied after another
410+
multi-sample transform while controlling how deep the mapping goes.
396411
unpack_items: whether to unpack input `data` with `*` as parameters for the callable function of transform.
397412
defaults to `False`.
398413
log_stats: this optional parameter allows you to specify a logger by name for logging of pipeline execution.

monai/transforms/transform.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,7 @@ def apply_transform(
117117
Args:
118118
transform: a callable to be used to transform `data`.
119119
data: an object to be transformed.
120-
map_items: whether to apply transform to each item in `data`,
121-
if `data` is a list or tuple. Defaults to True.
122-
it can also be an int, if so, recursively map the items in `data` `map_items` times.
123-
map_items: Controls whether to apply a transformation to each item in `data`. If `data` is a list or tuple,
120+
map_items: controls whether to apply a transformation to each item in `data`. If `data` is a list or tuple,
124121
it can behave as follows:
125122
- Defaults to True, which is equivalent to `map_items=1`, meaning the transformation will be applied
126123
to the first level of items in `data`.

0 commit comments

Comments
 (0)