Skip to content

Commit

Permalink
Comment on implementation of unzip2 & unzip3
Browse files Browse the repository at this point in the history
  • Loading branch information
jakevdp committed Apr 14, 2022
1 parent 7ad1120 commit 72470de
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions jax/_src/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def safe_map(f, *args):
return list(map(f, *args))

def unzip2(xys):
"""Unzip sequence of length-2 tuples into two tuples."""
# Note: we deliberately don't use zip(*xys) because it is lazily evaluated,
# is too permissive about inputs, and does not guarantee a length-2 output.
xs = []
ys = []
for x, y in xys:
Expand All @@ -55,6 +58,9 @@ def unzip2(xys):
return tuple(xs), tuple(ys)

def unzip3(xyzs):
"""Unzip sequence of length-3 tuples into three tuples."""
# Note: we deliberately don't use zip(*xyzs) because it is lazily evaluated,
# is too permissive about inputs, and does not guarantee a length-3 output.
xs = []
ys = []
zs = []
Expand Down

0 comments on commit 72470de

Please sign in to comment.