Made print statements python 3 compatible

master
Per A Brodtkorb 9 years ago
parent 5a6b1a6a3a
commit b57307ab7c

@ -334,19 +334,19 @@ def shiftdim(x, n=None):
def test_shiftdim(): def test_shiftdim():
a = np.arange(6).reshape((1, 1, 3, 1, 2)) a = np.arange(6).reshape((1, 1, 3, 1, 2))
print a.shape print(a.shape)
print a.ndim print(a.ndim)
print range(a.ndim) print(range(a.ndim))
# move items 2 places to the left so that x0 <- x2, x1 <- x3, etc # move items 2 places to the left so that x0 <- x2, x1 <- x3, etc
print np.roll(range(a.ndim), -2) print(np.roll(range(a.ndim), -2))
print a.transpose(np.roll(range(a.ndim), -2)) # transposition of the axes print(a.transpose(np.roll(range(a.ndim), -2))) # transposition of the axes
# with a matrix 2x2, A.transpose((1,0)) would be the transpose of A # with a matrix 2x2, A.transpose((1,0)) would be the transpose of A
b = shiftdim(a) b = shiftdim(a)
print b.shape print(b.shape)
c = shiftdim(b, -2) c = shiftdim(b, -2)
print c.shape print(c.shape)
print(c == a) print(c == a)

@ -58,7 +58,7 @@ def f2py_call_str():
break break
try: try:
print 'found f2py in:', f2py_path print('found f2py in:', f2py_path)
return f2py_call return f2py_call
except NameError: except NameError:
raise UserWarning('Couldn\'t locate f2py. ' raise UserWarning('Couldn\'t locate f2py. '

@ -39,7 +39,10 @@ def delete_text_object(gidtxt, figure=None, axis=None, verbose=False):
figure = plotbackend.gcf() figure = plotbackend.gcf()
if axis is None: if axis is None:
axis = figure.gca() axis = figure.gca()
lmatchfun = lambda x: _matchfun(x, gidtxt)
def lmatchfun(x):
return _matchfun(x, gidtxt)
objs = axis.findobj(lmatchfun) objs = axis.findobj(lmatchfun)
for obj in objs: for obj in objs:
try: try:

@ -1415,7 +1415,7 @@ def main():
x = np.linspace(0, np.pi / 2) x = np.linspace(0, np.pi / 2)
_q0 = np.trapz(humps(x), x) _q0 = np.trapz(humps(x), x)
[q, err] = romberg(humps, 0, np.pi / 2, 1e-4) [q, err] = romberg(humps, 0, np.pi / 2, 1e-4)
print q, err print(q, err)
def test_docstrings(): def test_docstrings():

@ -26,7 +26,7 @@ from wafo.plotbackend import plotbackend as plt
try: try:
from wafo import fig from wafo import fig
except ImportError: except ImportError:
print 'fig import only supported on Windows' warnings.warn('fig import only supported on Windows')
def _invnorm(q): def _invnorm(q):

@ -597,7 +597,7 @@ def parse_kwargs(options, **kwargs):
Example Example
>>> opt = dict(arg1=2, arg2=3) >>> opt = dict(arg1=2, arg2=3)
>>> opt = parse_kwargs(opt,arg2=100) >>> opt = parse_kwargs(opt,arg2=100)
>>> print opt >>> print(opt)
{'arg1': 2, 'arg2': 100} {'arg1': 2, 'arg2': 100}
>>> opt2 = dict(arg2=101) >>> opt2 = dict(arg2=101)
>>> opt = parse_kwargs(opt,**opt2) >>> opt = parse_kwargs(opt,**opt2)

@ -126,7 +126,7 @@ if __name__ == '__main__':
self.hypot) self.hypot)
for p in Point(3, 4), Point(14, 5), Point(9. / 7, 6): for p in Point(3, 4), Point(14, 5), Point(9. / 7, 6):
print p print(p)
class Point(namedtuple('Point', 'x y')): class Point(namedtuple('Point', 'x y')):
'''Point class with optimized _make() and _replace() '''Point class with optimized _make() and _replace()
@ -137,8 +137,8 @@ if __name__ == '__main__':
def _replace(self, _map=map, **kwds): def _replace(self, _map=map, **kwds):
return self._make(_map(kwds.get, ('x', 'y'), self)) return self._make(_map(kwds.get, ('x', 'y'), self))
print Point(11, 22)._replace(x=100) print(Point(11, 22)._replace(x=100))
import doctest import doctest
TestResults = namedtuple('TestResults', 'failed attempted') TestResults = namedtuple('TestResults', 'failed attempted')
print TestResults(*doctest.testmod()) print(TestResults(*doctest.testmod()))

@ -491,7 +491,7 @@ def plot2d(axis, wdata, plotflag, *args, **kwds):
'Only the first 12 levels will be listed in table.') 'Only the first 12 levels will be listed in table.')
clvals = PL[:ncl] if isPL else clvec[:ncl] clvals = PL[:ncl] if isPL else clvec[:ncl]
# print contour level text # print(contour level text)
unused_axcl = cltext(clvals, percent=isPL) unused_axcl = cltext(clvals, percent=isPL)
elif any(plotflag == [7, 9]): elif any(plotflag == [7, 9]):
axis.clabel(h) axis.clabel(h)

@ -251,7 +251,7 @@ if __name__ == '__main__':
wb = Waitbar('Waitbar example') wb = Waitbar('Waitbar example')
# wb2 = Waitbar2('Waitbar example') # wb2 = Waitbar2('Waitbar example')
for i in xrange(20): for i in xrange(20):
print wb.update(i * 5) print(wb.update(i * 5))
# wb2.update(i) # wb2.update(i)
sleep(0.1) sleep(0.1)
wb.close() wb.close()

Loading…
Cancel
Save