diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-04-19 18:40:40 +0100 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-04-19 18:42:12 +0100 |
commit | 871bd932dcea92891fbbc2edc1ec1246c9394170 (patch) | |
tree | 89981a8e916d34757feae8ac27abd0827926ecb9 /numpy/lib/recfunctions.py | |
parent | f031cdf83593907431ca2666d8484cb1c36315bd (diff) | |
parent | 3b2a7a761d5ceef3b9dcca3fff10380cb7a6f976 (diff) | |
download | numpy-871bd932dcea92891fbbc2edc1ec1246c9394170.tar.gz |
Merge remote-tracking branch 'upstream/master' into remove-setslice
Diffstat (limited to 'numpy/lib/recfunctions.py')
-rw-r--r-- | numpy/lib/recfunctions.py | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/numpy/lib/recfunctions.py b/numpy/lib/recfunctions.py index 4ae1079d2..d3d58d1f2 100644 --- a/numpy/lib/recfunctions.py +++ b/numpy/lib/recfunctions.py @@ -275,24 +275,20 @@ def izip_records(seqarrays, fill_value=None, flatten=True): flatten : {True, False}, Whether to """ - # OK, that's a complete ripoff from Python2.6 itertools.izip_longest - def sentinel(counter=([fill_value] * (len(seqarrays) - 1)).pop): - "Yields the fill_value or raises IndexError" - yield counter() - # - fillers = itertools.repeat(fill_value) - iters = [itertools.chain(it, sentinel(), fillers) for it in seqarrays] + # Should we flatten the items, or just use a nested approach if flatten: zipfunc = _izip_fields_flat else: zipfunc = _izip_fields - # - try: - for tup in zip(*iters): - yield tuple(zipfunc(tup)) - except IndexError: - pass + + if sys.version_info[0] >= 3: + zip_longest = itertools.zip_longest + else: + zip_longest = itertools.izip_longest + + for tup in zip_longest(*seqarrays, fillvalue=fill_value): + yield tuple(zipfunc(tup)) def _fix_output(output, usemask=True, asrecarray=False): |