Skip to content

Commit

Permalink
add examples in fn: is_homo_list and list_nested_level
Browse files Browse the repository at this point in the history
  • Loading branch information
zzachw committed Nov 15, 2022
1 parent 3e1edb1 commit 7b49dc9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pyhealth/datasets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ def list_nested_level(l: List) -> int:
Returns:
int, the nested level of the list.
Examples:
>>> list_nested_level([1, 2, 3])
1
>>> list_nested_level([[1, 2, 3], [4, 5, 6]])
2
>>> list_nested_level([1, [2, 3], 4])
2
"""
if not isinstance(l, list):
return 0
Expand All @@ -57,6 +65,16 @@ def is_homo_list(l: List) -> bool:
Returns:
bool, True if the list is homogeneous, False otherwise.
Examples:
>>> is_homo_list([1, 2, 3])
True
>>> is_homo_list([])
True
>>> is_homo_list([1, 2, "3"])
False
>>> is_homo_list([1, 2, 3, [4, 5, 6]])
False
"""
if not l:
return True
Expand Down

0 comments on commit 7b49dc9

Please sign in to comment.