Skip to content

Commit 0037679

Browse files
atbenmurrayNic-Ma
andauthored
has_status_keys needs a default value for default_message (#6572)
Fixes #6569. ### Description A few sentences describing the changes proposed in this pull request. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [x] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [x] In-line docstrings updated. - [x] Documentation updated, tested `make html` command in the `docs/` folder. Signed-off-by: Ben Murray <ben.murray@gmail.com> Co-authored-by: Nic Ma <nma@nvidia.com>
1 parent 762c10f commit 0037679

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

monai/transforms/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,7 @@ def check_applied_operations(entry: list | dict, status_key: str, default_messag
20012001
return []
20022002

20032003

2004-
def has_status_keys(data: torch.Tensor, status_key: Any, default_msg: str):
2004+
def has_status_keys(data: torch.Tensor, status_key: Any, default_message: str = "No message provided"):
20052005
"""
20062006
Checks whether a given tensor is has a particular status key message on any of its
20072007
applied operations. If it doesn't, it returns the tuple `(False, None)`. If it does
@@ -2021,7 +2021,7 @@ def has_status_keys(data: torch.Tensor, status_key: Any, default_msg: str):
20212021
Args:
20222022
data: a `torch.Tensor` or `MetaTensor` or collections of torch.Tensor or MetaTensor, as described above
20232023
status_key: the status key to look for, from `TraceStatusKeys`
2024-
default_msg: a default message to use if the status key entry doesn't have a message set
2024+
default_message: a default message to use if the status key entry doesn't have a message set
20252025
20262026
Returns:
20272027
A tuple. The first entry is `False` or `True`. The second entry is the status messages that can be used for the
@@ -2031,15 +2031,15 @@ def has_status_keys(data: torch.Tensor, status_key: Any, default_msg: str):
20312031
status_key_occurrences = list()
20322032
if isinstance(data, (list, tuple)):
20332033
for d in data:
2034-
_, reasons = has_status_keys(d, status_key, default_msg)
2034+
_, reasons = has_status_keys(d, status_key, default_message)
20352035
if reasons is not None:
20362036
status_key_occurrences.extend(reasons)
20372037
elif isinstance(data, monai.data.MetaTensor):
20382038
for op in data.applied_operations:
2039-
status_key_occurrences.extend(check_applied_operations(op, status_key, default_msg))
2039+
status_key_occurrences.extend(check_applied_operations(op, status_key, default_message))
20402040
elif isinstance(data, dict):
20412041
for d in data.values():
2042-
_, reasons = has_status_keys(d, status_key, default_msg)
2042+
_, reasons = has_status_keys(d, status_key, default_message)
20432043
if reasons is not None:
20442044
status_key_occurrences.extend(reasons)
20452045

0 commit comments

Comments
 (0)