Permalink
Browse files

REF remove 2to3

  • Loading branch information...
1 parent 1036171 commit 3c342d2eabbe1de06888250bf2947aac74e3603f @kwgoodman committed Oct 28, 2013
View
@@ -126,7 +126,7 @@ def __init__(self, x, label=None, dtype=None, validate=True):
count = {}
for li in l:
count[li] = count.get(li, 0) + 1
- for key, value in count.iteritems():
+ for key, value in count.items():
if value > 1:
break
msg = "Elements of label not unique along axis %d. "
@@ -2695,9 +2695,9 @@ def maplabel(self, func, axis=None, copy=True):
y = self
if axis is None:
for ax in range(y.ndim):
- y.label[ax] = map(func, y.label[ax])
+ y.label[ax] = list(map(func, y.label[ax]))
else:
- y.label[axis] = map(func, y.label[axis])
+ y.label[axis] = list(map(func, y.label[axis]))
return y
# Moving window statistics ----------------------------------------------
@@ -4480,9 +4480,9 @@ def totuples(self):
"""
yf = self.flatten()
- z = zip(*yf.label[0])
+ z = list(zip(*yf.label[0]))
z.append(yf.x.tolist())
- return zip(*z)
+ return list(zip(*z))
@staticmethod
def fromtuples(data):
@@ -4551,7 +4551,7 @@ def fromtuples(data):
return larry([])
else:
# Split data into label and x
- labels = zip(*data)
+ labels = list(zip(*data))
xs = labels.pop(-1)
# Determine labels, shape, and index into array
x, label = fromlists(xs, labels)
@@ -4629,7 +4629,7 @@ def fromlist(data):
if len(data) == 0:
return larry([])
else:
- x, label = fromlists(data[0], zip(*data[1]))
+ x, label = fromlists(data[0], list(zip(*data[1])))
return larry(x, label)
def todict(self):
@@ -4699,7 +4699,7 @@ def fromdict(data):
[ 3., 4.]])
"""
- return larry.fromlist([data.values(), data.keys()])
+ return larry.fromlist([list(data.values()), list(data.keys())])
def tocsv(self, filename, delimiter=','):
"""
@@ -5166,7 +5166,7 @@ def slicemaker(index, labelindex, axis):
def labels2indices(label, labels):
"Convert list of labels to indices"
try:
- indices = map(label.index, labels)
+ indices = list(map(label.index, labels))
except ValueError:
raise ValueError('Could not map label to index value.')
return indices
View
@@ -1,13 +1,6 @@
"label (list of lists) functions"
try:
- import itertools.izip as zip
-except ImportError: # Python 3
- pass
-
-import numpy as np
-
-try:
# The c version is faster...
from la.cflabel import listmap
except ImportError:
View
@@ -636,11 +636,11 @@ def _load_label(group, ndim):
labellist = g[:].tolist()
datetime_type = group[str(i)].attrs['datetime_type']
if datetime_type == 'date':
- labellist = map(datetime.date.fromordinal, labellist)
+ labellist = list(map(datetime.date.fromordinal, labellist))
elif datetime_type == 'time':
- labellist = map(tuple2time, labellist)
+ labellist = list(map(tuple2time, labellist))
elif datetime_type == 'datetime':
- labellist = map(tuple2datetime, labellist)
+ labellist = list(map(tuple2datetime, labellist))
label.append(labellist)
return label
@@ -658,14 +658,14 @@ def _list2array(x):
msg += 'same type.'
raise TypeError(msg)
if type0 == datetime.date:
- x = map(datetime.date.toordinal, x)
+ x = list(map(datetime.date.toordinal, x))
datetime_type = 'date'
elif type0 == datetime.time:
- x = map(time2tuple, x)
+ x = list(map(time2tuple, x))
datetime_type = 'time'
dtype = "i4,i4,i4,i4"
elif type0 == datetime.datetime:
- x = map(datetime2tuple, x)
+ x = list(map(datetime2tuple, x))
datetime_type = 'datetime'
dtype = ','.join(["i4" for i in range(len(x[0]))])
return np.asarray(x, dtype=dtype), datetime_type
View
@@ -25,7 +25,7 @@ def functions():
def test_all_nan():
"Test larry methods for proper handling of all NaN input"
err_msg = "%s did not return NaN"
- for parameters, methods in functions().iteritems():
+ for parameters, methods in functions().items():
for method in methods:
with np.errstate(invalid='ignore', divide='ignore'):
actual = getattr(lar(), method)(*parameters)
@@ -2,8 +2,12 @@
# For support of python 2.5
from __future__ import with_statement
+try:
+ from cStringIO import StringIO
+except ImportError: # Python 3
+ from io import StringIO
+
from copy import deepcopy
-from StringIO import StringIO
import numpy as np
nan = np.nan
@@ -3538,7 +3538,7 @@ def take_test():
y = la.rand(*shape)
for axis in range(y.ndim):
for i in range(1, y.shape[axis]):
- idx = range(i)[::-1]
+ idx = list(range(i))[::-1]
ytake = y.take(idx, axis=axis)
index = [slice(None)] * y.ndim
index[axis] = idx
@@ -186,7 +186,7 @@ def test_reduce_shape():
msg = 'larry.%s failed for shape %s and axis %s'
for method in reduce_methods():
for shape in get_shapes():
- axeslist = [None] + range(len(shape))
+ axeslist = [None] + list(range(len(shape)))
for axis in axeslist:
arr = np.zeros(shape)
npmethod = getattr(arr, method['np'])
View
@@ -20,7 +20,7 @@ def listmap_test():
msg = "listmap failed on list1=%s and list2=%s and ignore_unmappable=%s"
for i in range(100):
np.random.shuffle(list2)
- idx1 = map(list1.index, list2)
+ idx1 = list(map(list1.index, list2))
idx2 = listmap(list1, list2)
ignore_unmappable = False
yield assert_equal, idx1, idx2, msg % (list1, list2, ignore_unmappable)
@@ -34,7 +34,7 @@ def listmap_unmappable_test():
list1 = list(range(6))
list2 = list(range(5))
np.random.shuffle(list2)
- idx1 = map(list1.index, list2)
+ idx1 = list(map(list1.index, list2))
list2 = ['unmappable #1'] + list2 + ['unmappable #2']
ignore_unmappable = True
idx2 = listmap(list1, list2, ignore_unmappable=ignore_unmappable)
@@ -56,7 +56,7 @@ def listmap_fill_test():
msg = "listmap_fill failed on list1=%s and list2=%s"
for i in range(100):
np.random.shuffle(list2)
- idx1 = map(list1.index, list2)
+ idx1 = list(map(list1.index, list2))
idx2, ignore = listmap_fill(list1, list2)
yield assert_equal, idx1, idx2, msg % (list1, list2)
View
@@ -210,4 +210,3 @@ def fromlists(xs, labels):
x.fill(np.nan)
x[index] = xs
return x, label
-
View
@@ -53,7 +53,7 @@ def cross_validation(n, kfold, shuffle=None):
raise ValueError("`kfold` must be two or greater.")
if kfold > n:
raise ValueError("`kfold` cannot be greater than `n`")
- index = range(n)
+ index = list(range(n))
if shuffle is None:
np.random.shuffle(index)
else:
@@ -30,7 +30,7 @@ def test_isa():
t[(np.array(1)[()], 6)] = (True, False)
t[(np.array(1.1)[()], 7)] = (False, True)
t[(1j, 8)] = (False, False)
- for key, value in t.iteritems():
+ for key, value in t.items():
key = key[0]
msg = '\nisint(' + str(key) + ')'
yield assert_equal, isint(key), value[0], msg
View
@@ -4,11 +4,6 @@
from distutils.core import setup
from distutils.extension import Extension
-try:
- from distutils.command.build_py import build_py_2to3 as build_py
-except ImportError:
- from distutils.command.build_py import build_py
-
CLASSIFIERS = ["Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Science/Research",
@@ -79,7 +74,6 @@
package_data=PACKAGE_DATA,
requires=REQUIRES,
ext_modules = [Extension("la.cflabel", ["la/src/cflabel.c"])],
- cmdclass={'build_py': build_py}
)
except SystemExit:
# Probably clistmap.c failed to compile, so use slower python version
@@ -102,5 +96,4 @@
packages=PACKAGES,
package_data=PACKAGE_DATA,
requires=REQUIRES,
- cmdclass={'build_py': build_py}
)

0 comments on commit 3c342d2

Please sign in to comment.