Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3f2c789

Browse files
committed
Merge pull request numpy#3244 from charris/2to3-apply-zip-fixer
2to3: Apply zip fixer.
2 parents 61c5ac6 + 0dfe67a commit 3f2c789

13 files changed

Lines changed: 54 additions & 54 deletions

File tree

doc/sphinxext/numpydoc/compiler_unparse.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
if sys.version_info[0] >= 3:
1919
from io import StringIO
2020
else:
21-
from io import StringIO
21+
from StringIO import StringIO
2222

2323
def unparse(ast, single_line_functions=False):
2424
s = StringIO()
@@ -106,13 +106,13 @@ def _And(self, t):
106106
if i != len(t.nodes)-1:
107107
self._write(") and (")
108108
self._write(")")
109-
109+
110110
def _AssAttr(self, t):
111111
""" Handle assigning an attribute of an object
112112
"""
113113
self._dispatch(t.expr)
114114
self._write('.'+t.attrname)
115-
115+
116116
def _Assign(self, t):
117117
""" Expression Assignment such as "a = 1".
118118
@@ -150,36 +150,36 @@ def _AssTuple(self, t):
150150
def _AugAssign(self, t):
151151
""" +=,-=,*=,/=,**=, etc. operations
152152
"""
153-
153+
154154
self._fill()
155155
self._dispatch(t.node)
156156
self._write(' '+t.op+' ')
157157
self._dispatch(t.expr)
158158
if not self._do_indent:
159159
self._write(';')
160-
160+
161161
def _Bitand(self, t):
162162
""" Bit and operation.
163163
"""
164-
164+
165165
for i, node in enumerate(t.nodes):
166166
self._write("(")
167167
self._dispatch(node)
168168
self._write(")")
169169
if i != len(t.nodes)-1:
170170
self._write(" & ")
171-
171+
172172
def _Bitor(self, t):
173173
""" Bit or operation
174174
"""
175-
175+
176176
for i, node in enumerate(t.nodes):
177177
self._write("(")
178178
self._dispatch(node)
179179
self._write(")")
180180
if i != len(t.nodes)-1:
181181
self._write(" | ")
182-
182+
183183
def _CallFunc(self, t):
184184
""" Function call.
185185
"""
@@ -254,7 +254,7 @@ def _From(self, t):
254254
self._write(name)
255255
if asname is not None:
256256
self._write(" as "+asname)
257-
257+
258258
def _Function(self, t):
259259
""" Handle function definitions
260260
"""

numpy/core/tests/test_getlimits.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ def test_singleton(self,level=2):
4343

4444
class TestIinfo(TestCase):
4545
def test_basic(self):
46-
dts = zip(['i1', 'i2', 'i4', 'i8',
46+
dts = list(zip(['i1', 'i2', 'i4', 'i8',
4747
'u1', 'u2', 'u4', 'u8'],
4848
[np.int8, np.int16, np.int32, np.int64,
49-
np.uint8, np.uint16, np.uint32, np.uint64])
49+
np.uint8, np.uint16, np.uint32, np.uint64]))
5050
for dt1, dt2 in dts:
5151
assert_equal(iinfo(dt1).min, iinfo(dt2).min)
5252
assert_equal(iinfo(dt1).max, iinfo(dt2).max)

numpy/core/tests/test_nditer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ def assign_iter(i):
15721572
assert_equal(i[0], 0)
15731573
i[1] = 1
15741574
assert_equal(i[0:2], [0,1])
1575-
assert_equal([[x[0][()],x[1][()]] for x in i], zip(list(range(6)), [1]*6))
1575+
assert_equal([[x[0][()],x[1][()]] for x in i], list(zip(range(6), [1]*6)))
15761576

15771577
def test_iter_buffered_cast_simple():
15781578
# Test that buffering can handle a simple cast

numpy/core/tests/test_ufunc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_pickle_withstring(self):
2020
def test_reduceat_shifting_sum(self) :
2121
L = 6
2222
x = np.arange(L)
23-
idx = np.array(zip(np.arange(L-2), np.arange(L-2)+2)).ravel()
23+
idx = np.array(list(zip(np.arange(L - 2), np.arange(L - 2) + 2))).ravel()
2424
assert_array_equal(np.add.reduceat(x,idx)[::2], [1,3,5,7])
2525

2626
def test_generic_loops(self) :

numpy/lib/_iotools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ def easy_dtype(ndtype, names=None, defaultfmt="f%i", **validationargs):
855855
if nbtypes == 0:
856856
formats = tuple([ndtype.type] * len(names))
857857
names = validate(names, defaultfmt=defaultfmt)
858-
ndtype = np.dtype(zip(names, formats))
858+
ndtype = np.dtype(list(zip(names, formats)))
859859
# Structured dtype: just validate the names as needed
860860
else:
861861
ndtype.names = validate(names, nbfields=nbtypes,

numpy/lib/npyio.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,11 +1664,11 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
16641664
# rows[i] = tuple([convert(val)
16651665
# for (convert, val) in zip(conversionfuncs, vals)])
16661666
if loose:
1667-
rows = zip(*[[converter._loose_call(_r) for _r in map(itemgetter(i), rows)]
1668-
for (i, converter) in enumerate(converters)])
1667+
rows = list(zip(*[[converter._loose_call(_r) for _r in map(itemgetter(i), rows)]
1668+
for (i, converter) in enumerate(converters)]))
16691669
else:
1670-
rows = zip(*[[converter._strict_call(_r) for _r in map(itemgetter(i), rows)]
1671-
for (i, converter) in enumerate(converters)])
1670+
rows = list(zip(*[[converter._strict_call(_r) for _r in map(itemgetter(i), rows)]
1671+
for (i, converter) in enumerate(converters)]))
16721672
# Reset the dtype
16731673
data = rows
16741674
if dtype is None:
@@ -1693,8 +1693,8 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
16931693
mdtype = [(defaultfmt % i, np.bool)
16941694
for (i, dt) in enumerate(column_types)]
16951695
else:
1696-
ddtype = zip(names, column_types)
1697-
mdtype = zip(names, [np.bool] * len(column_types))
1696+
ddtype = list(zip(names, column_types))
1697+
mdtype = list(zip(names, [np.bool] * len(column_types)))
16981698
output = np.array(data, dtype=ddtype)
16991699
if usemask:
17001700
outputmask = np.array(masks, dtype=mdtype)

numpy/lib/tests/test_arraysetops.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ def check_all(a, b, i1, i2, dt):
6161

6262
# test for structured arrays
6363
dt = [('', 'i'), ('', 'i')]
64-
aa = np.array(zip(a,a), dt)
65-
bb = np.array(zip(b,b), dt)
64+
aa = np.array(list(zip(a,a)), dt)
65+
bb = np.array(list(zip(b,b)), dt)
6666
check_all(aa, bb, i1, i2, dt)
6767

6868

numpy/lib/tests/test_io.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ def test_usecols(self):
517517
c = TextIO(data)
518518
names = ['stid', 'temp']
519519
dtypes = ['S4', 'f8']
520-
arr = np.loadtxt(c, usecols=(0, 2), dtype=zip(names, dtypes))
520+
arr = np.loadtxt(c, usecols=(0, 2), dtype=list(zip(names, dtypes)))
521521
assert_equal(arr['stid'], [b"JOE", b"BOB"])
522522
assert_equal(arr['temp'], [25.3, 27.9])
523523

@@ -1119,7 +1119,7 @@ def test_usecols_with_structured_dtype(self):
11191119
data = TextIO("JOE 70.1 25.3\nBOB 60.5 27.9")
11201120
names = ['stid', 'temp']
11211121
dtypes = ['S4', 'f8']
1122-
test = np.ndfromtxt(data, usecols=(0, 2), dtype=zip(names, dtypes))
1122+
test = np.ndfromtxt(data, usecols=(0, 2), dtype=list(zip(names, dtypes)))
11231123
assert_equal(test['stid'], [b"JOE", b"BOB"])
11241124
assert_equal(test['temp'], [25.3, 27.9])
11251125

numpy/lib/tests/test_recfunctions.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -543,11 +543,11 @@ def test_checktitles(self):
543543

544544
class TestJoinBy(TestCase):
545545
def setUp(self):
546-
self.a = np.array(zip(np.arange(10), np.arange(50, 60),
547-
np.arange(100, 110)),
546+
self.a = np.array(list(zip(np.arange(10), np.arange(50, 60),
547+
np.arange(100, 110))),
548548
dtype=[('a', int), ('b', int), ('c', int)])
549-
self.b = np.array(zip(np.arange(5, 15), np.arange(65, 75),
550-
np.arange(100, 110)),
549+
self.b = np.array(list(zip(np.arange(5, 15), np.arange(65, 75),
550+
np.arange(100, 110))),
551551
dtype=[('a', int), ('b', int), ('d', int)])
552552
#
553553
def test_inner_join(self):
@@ -620,11 +620,11 @@ def test_leftouter_join(self):
620620
class TestJoinBy2(TestCase):
621621
@classmethod
622622
def setUp(cls):
623-
cls.a = np.array(zip(np.arange(10), np.arange(50, 60),
624-
np.arange(100, 110)),
623+
cls.a = np.array(list(zip(np.arange(10), np.arange(50, 60),
624+
np.arange(100, 110))),
625625
dtype=[('a', int), ('b', int), ('c', int)])
626-
cls.b = np.array(zip(np.arange(10), np.arange(65, 75),
627-
np.arange(100, 110)),
626+
cls.b = np.array(list(zip(np.arange(10), np.arange(65, 75),
627+
np.arange(100, 110))),
628628
dtype=[('a', int), ('b', int), ('d', int)])
629629

630630
def test_no_r1postfix(self):
@@ -660,12 +660,12 @@ def test_no_r2postfix(self):
660660
assert_equal(test, control)
661661

662662
def test_two_keys_two_vars(self):
663-
a = np.array(zip(np.tile([10,11],5),np.repeat(np.arange(5),2),
664-
np.arange(50, 60), np.arange(10,20)),
663+
a = np.array(list(zip(np.tile([10,11],5),np.repeat(np.arange(5),2),
664+
np.arange(50, 60), np.arange(10,20))),
665665
dtype=[('k', int), ('a', int), ('b', int),('c',int)])
666666

667-
b = np.array(zip(np.tile([10,11],5),np.repeat(np.arange(5),2),
668-
np.arange(65, 75), np.arange(0,10)),
667+
b = np.array(list(zip(np.tile([10,11],5),np.repeat(np.arange(5),2),
668+
np.arange(65, 75), np.arange(0,10))),
669669
dtype=[('k', int), ('a', int), ('b', int), ('c',int)])
670670

671671
control = np.array([(10, 0, 50, 65, 10, 0), (11, 0, 51, 66, 11, 1),

numpy/ma/mrecords.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ def fromarrays(arraylist, dtype=None, shape=None, formats=None,
511511
dtype=dtype, shape=shape, formats=formats,
512512
names=names, titles=titles, aligned=aligned,
513513
byteorder=byteorder).view(mrecarray)
514-
_array._mask.flat = zip(*masklist)
514+
_array._mask.flat = list(zip(*masklist))
515515
if fill_value is not None:
516516
_array.fill_value = fill_value
517517
return _array

0 commit comments

Comments
 (0)