From e346d6b11b4e9c69c4d51750f068bca09260055c Mon Sep 17 00:00:00 2001 From: cgohlke Date: Sat, 29 Sep 2012 15:42:51 -0700 Subject: [PATCH 1/2] Fix: round function is not provided by libc.math on all platforms --- skimage/transform/_hough_transform.pyx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/skimage/transform/_hough_transform.pyx b/skimage/transform/_hough_transform.pyx index 906e4464..ef1cf700 100644 --- a/skimage/transform/_hough_transform.pyx +++ b/skimage/transform/_hough_transform.pyx @@ -2,7 +2,7 @@ cimport cython import numpy as np cimport numpy as np from random import randint -from libc.math cimport abs, fabs, sqrt, ceil, floor, round +from libc.math cimport abs, fabs, sqrt, ceil, floor from libc.stdlib cimport rand @@ -13,6 +13,10 @@ cdef double PI_2 = 1.5707963267948966 cdef double NEG_PI_2 = -PI_2 +cdef inline int round(double r): + return ((r + 0.5) if (r > 0.0) else (r - 0.5)) + + @cython.boundscheck(False) def _hough(np.ndarray img, np.ndarray[ndim=1, dtype=np.double_t] theta=None): From 0cf582865ecaafb68f42a85900b319c0da86c133 Mon Sep 17 00:00:00 2001 From: cgohlke Date: Sat, 29 Sep 2012 15:45:53 -0700 Subject: [PATCH 2/2] Fix: round function is not provided by libc.math on all platforms --- skimage/_shared/interpolation.pyx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/skimage/_shared/interpolation.pyx b/skimage/_shared/interpolation.pyx index 3150f41b..0922173d 100644 --- a/skimage/_shared/interpolation.pyx +++ b/skimage/_shared/interpolation.pyx @@ -2,7 +2,11 @@ #cython: boundscheck=False #cython: nonecheck=False #cython: wraparound=False -from libc.math cimport ceil, floor, round +from libc.math cimport ceil, floor + + +cdef inline int round(double r): + return ((r + 0.5) if (r > 0.0) else (r - 0.5)) cdef inline double nearest_neighbour_interpolation(double* image, int rows,