[python-dtcwt] 151/497: opencl: fix for non-floor division in Python3

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Tue Jul 21 18:05:59 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/sid
in repository python-dtcwt.

commit cfab65e3d51ae87ff274bba2670ad359534dca04
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date:   Thu Nov 7 18:29:07 2013 +0000

    opencl: fix for non-floor division in Python3
    
    In Python 3, the / operator has changed its behaviour. The // operator
    has been around in Python forever, use it instead. For good measure,
    import the non-floor / operator to catch further abuses in Python 2 too.
---
 dtcwt/opencl/lowlevel.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/dtcwt/opencl/lowlevel.py b/dtcwt/opencl/lowlevel.py
index 34743e1..c528649 100644
--- a/dtcwt/opencl/lowlevel.py
+++ b/dtcwt/opencl/lowlevel.py
@@ -1,3 +1,5 @@
+from __future__ import division
+
 # Wrap importing of pyopencl in a try/except block since it is not an error to
 # not have OpenCL installed when using dtcwt.
 try:
@@ -262,11 +264,11 @@ def _apply_kernel(X, h, kern, output, axis=0, elementstep=1, extra_kernel_args=N
 
     global_shape = list(int(np.ceil(x/float(y))*y) for x, y in zip(work_shape, local_shape))
 
-    X_strides = struct.pack('iiii', *(tuple(s/X_device.dtype.itemsize for s in X_device.strides) + (0,0,0,0))[:4])
+    X_strides = struct.pack('iiii', *(tuple(s//X_device.dtype.itemsize for s in X_device.strides) + (0,0,0,0))[:4])
     X_shape = struct.pack('iiii', *(tuple(X_device.shape) + (1,1,1,1))[:4])
     X_offset = np.int32(X_device.offset)
 
-    Y_strides = struct.pack('iiii', *(tuple(s/output.dtype.itemsize for s in output.strides) + (0,0,0,0))[:4])
+    Y_strides = struct.pack('iiii', *(tuple(s//output.dtype.itemsize for s in output.strides) + (0,0,0,0))[:4])
     Y_shape = struct.pack('iiii', *(tuple(output.shape) + (1,1,1,1))[:4])
     Y_offset = np.int32(output.offset)
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-dtcwt.git



More information about the debian-science-commits mailing list