Skip to content

Commit 801ef8e

Browse files
committed
updated docstring for combine_args
1 parent 0c8d588 commit 801ef8e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tesseract_jax/tesseract_compat.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@
1414

1515

1616
def combine_args(args0: Sequence, args1: Sequence, mask: Sequence[bool]) -> tuple:
17-
"""Merge the elements of two lists based on a mask."""
17+
"""Merge the elements of two lists based on a mask.
18+
19+
The length of the two lists is required to be equal to the length of the mask.
20+
`combine_args` will populate the new list according to the mask: if the mask evaluates
21+
to `False` it will take the next item of the first list, if it evaluate to `True` it will
22+
take from the second list.
23+
For example, merging the lists ["foo", "bar"] and [0, 1, 2] wih the mask [1, 0, 0, 1, 1]
24+
will return [0, "foo", "bar", 1, 2]
25+
"""
1826
assert sum(mask) == len(args1) and len(mask) - sum(mask) == len(args0)
1927
args0_iter, args1_iter = iter(args0), iter(args1)
2028
combined_args = [next(args1_iter) if m else next(args0_iter) for m in mask]

0 commit comments

Comments
 (0)