Skip to content

Commit 4889b7d

Browse files
committed
Python 3 compatibility: future imports, print function, xrange --> range
1 parent d915252 commit 4889b7d

File tree

19 files changed

+47
-27
lines changed

19 files changed

+47
-27
lines changed

examples/wlsqm_example.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -851,9 +851,9 @@ def test2d():
851851
# temp_x = np.array( [ (x,y) for x,y in zip(X2lin,Y2lin) ] )
852852
# out = wlsqm.interpolate_fit( xi, fi, dimension=2, order=fit_order, x=temp_x )
853853
# out = np.reshape( out, shp )
854-
# print
855-
# print "difference between Python and C API model interpolation:"
856-
# print out - W2 # should be close to zero
854+
# print()
855+
# print( "difference between Python and C API model interpolation:" )
856+
# print( out - W2 ) # should be close to zero
857857

858858
print()
859859
print( "function values at neighbor points:" )

wlsqm/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
JJ 2017-02-22
1919
"""
2020

21-
from __future__ import absolute_import # https://www.python.org/dev/peps/pep-0328/
21+
# absolute_import: https://www.python.org/dev/peps/pep-0328/
22+
from __future__ import division, print_function, absolute_import
2223

2324
__version__ = '0.1.4'
2425

wlsqm/fitter/defs.pxd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#
1212
# JJ 2016-11-30
1313

14+
from __future__ import absolute_import
15+
1416
# Algorithms for the solve step (expert mode).
1517
#
1618
cdef int ALGO_BASIC_c # fit just once

wlsqm/fitter/defs.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ Examples:
5959
JJ 2016-11-30
6060
"""
6161

62+
from __future__ import division, print_function, absolute_import
63+
6264
#################################################
6365
# C definitions (Cython level)
6466
#################################################

wlsqm/fitter/expert.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ This module contains the Python API for an "expert mode" in the LAPACK sense, wi
1717
JJ 2016-12-07
1818
"""
1919

20-
from __future__ import division
21-
from __future__ import absolute_import
20+
from __future__ import division, print_function, absolute_import
2221

2322
from libc.stdlib cimport malloc, free
2423
from libc.math cimport sqrt

wlsqm/fitter/impl.pxd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# cython: boundscheck = False
1717
# cython: cdivision = True
1818

19+
from __future__ import absolute_import
20+
1921
from cython cimport view
2022

2123
# See the infrasructure module for the definition of Case.

wlsqm/fitter/impl.pyx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@
1616
# cython: boundscheck = False
1717
# cython: cdivision = True
1818

19-
from __future__ import division
20-
from __future__ import absolute_import
19+
from __future__ import division, print_function, absolute_import
2120

2221
from libc.stdlib cimport malloc, free
2322
from libc.math cimport sqrt, log10
2423
from libc.math cimport fabs as c_abs
2524

2625
from numpy import asanyarray
27-
from numpy.linalg import cond # only needed for debug mode
2826

2927
cimport wlsqm.utils.lapackdrivers as drivers
3028

wlsqm/fitter/infra.pxd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#
1010
# JJ 2016-11-30
1111

12+
from __future__ import absolute_import
13+
1214
#################################################
1315
# Helper functions
1416
#################################################

wlsqm/fitter/infra.pyx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
# - max(nk_j) here too, same reason
3434
# - ntasks*no*sizeof(double) bytes for fi_tmp
3535

36-
from __future__ import division
37-
from __future__ import absolute_import
36+
from __future__ import division, print_function, absolute_import
3837

3938
from libc.stdlib cimport malloc, free
4039
from libc.math cimport sqrt
@@ -249,7 +248,7 @@ cdef Allocator* Allocator_new( int mode, int total_size_bytes ) nogil except <Al
249248
cdef void* Allocator_malloc( Allocator* self, int size_bytes ) nogil:
250249
if self.mode == ALLOC_MODE_PASSTHROUGH:
251250
# with gil:
252-
# print "directly allocating %d bytes" % (size_bytes)
251+
# print( "directly allocating %d bytes" % (size_bytes) ) # DEBUG
253252
return malloc( size_bytes )
254253

255254
# else...
@@ -262,12 +261,12 @@ cdef void* Allocator_malloc( Allocator* self, int size_bytes ) nogil:
262261
cdef int size_remaining = self.size_total - self.size_used
263262
if size_bytes > size_remaining:
264263
# with gil:
265-
# print "buffer full, cannot allocate %d bytes" % (size_bytes) # DEBUG
264+
# print( "buffer full, cannot allocate %d bytes" % (size_bytes) ) # DEBUG
266265
return <void*>0
267266

268267
cdef void* p
269268
with gil: # since we are called from Python threads only, we can use the GIL to make the operation thread-safe. (TODO/FIXME: well, not exactly, see e.g. http://www.slideshare.net/dabeaz/an-introduction-to-python-concurrency )
270-
# print "reserving %d bytes from buffer of size %d; after alloc, %d bytes remaining" % (size_bytes, self.size_total, size_remaining - size_bytes) # DEBUG
269+
# print( "reserving %d bytes from buffer of size %d; after alloc, %d bytes remaining" % (size_bytes, self.size_total, size_remaining - size_bytes) ) # DEBUG
271270
p = self.p
272271
self.p = <void*>( (<char*>p) + size_bytes )
273272
self.size_used += size_bytes

wlsqm/fitter/interp.pxd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#
99
# JJ 2016-11-30
1010

11+
from __future__ import absolute_import
12+
1113
from cython cimport view
1214

1315
cimport wlsqm.fitter.infra as infra

0 commit comments

Comments
 (0)