Skip to content

Commit

Permalink
Replace micro module with most recent version
Browse files Browse the repository at this point in the history
  • Loading branch information
hwikle-lanl committed Nov 4, 2024
1 parent 74997ec commit fd28ddd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/pavilion/micro.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,13 @@ def set_default(val: Optional[T], default: T) -> T:
return default

return val

def iterlen(itr: Iterator[T]) -> Tuple[int, Iterator[T]]:
"""Get the length of an iterator. Assumes the iterator is
finite; i.e. it eventually stops yielding new values.
Returns a copy of the iterator with the length. This is
necessary because the original iterator is consumed."""

t1, t2 = tee(itr)

return len(list(t1)), t2

0 comments on commit fd28ddd

Please sign in to comment.