From f55e878b8eb2643d040c683110e263074f0c8ab6 Mon Sep 17 00:00:00 2001 From: KrisKennaway Date: Sun, 29 Oct 2023 14:43:55 +0000 Subject: [PATCH] Mark nogil functions as noexcept to avoid warning from newer cython (#15) --- common.pyx | 6 +++--- dither_dhr.pyx | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common.pyx b/common.pyx index c048783..5ffc883 100644 --- a/common.pyx +++ b/common.pyx @@ -4,12 +4,12 @@ # cython: wraparound=False -cdef inline float clip(float a, float min_value, float max_value) nogil: +cdef inline float clip(float a, float min_value, float max_value) noexcept nogil: """Clip a value between min_value and max_value inclusive.""" return min(max(a, min_value), max_value) -cdef inline float3 convert_rgb_to_cam16ucs(float[:, ::1] rgb_to_cam16ucs, float r, float g, float b) nogil: +cdef inline float3 convert_rgb_to_cam16ucs(float[:, ::1] rgb_to_cam16ucs, float r, float g, float b) noexcept nogil: """Converts floating point (r,g,b) valueto 3-tuple in CAM16UCS colour space, via 24-bit RGB lookup matrix.""" cdef unsigned int rgb_24bit = ((r*255) << 16) + ((g*255) << 8) + (b*255) @@ -20,7 +20,7 @@ cdef inline float3 convert_rgb_to_cam16ucs(float[:, ::1] rgb_to_cam16ucs, float return res -cdef inline float colour_distance_squared(float[3] colour1, float[3] colour2) nogil: +cdef inline float colour_distance_squared(float[3] colour1, float[3] colour2) noexcept nogil: """Computes Euclidean squared distance between two floating-point colour 3-tuples.""" return ( diff --git a/dither_dhr.pyx b/dither_dhr.pyx index 83a2b64..b1a36e8 100644 --- a/dither_dhr.pyx +++ b/dither_dhr.pyx @@ -219,7 +219,7 @@ cdef int dither_lookahead(Dither* dither, unsigned char palette_depth, float[:, # quant_error: RGB quantization error to be diffused # cdef inline void apply_one_line(Dither* dither, int xl, int xr, int x, float[] image, int image_shape1, - float[] quant_error) nogil: + float[] quant_error) noexcept nogil: cdef int i, j cdef float error_fraction @@ -241,7 +241,7 @@ cdef inline void apply_one_line(Dither* dither, int xl, int xr, int x, float[] i # image: RGB pixel data, to be mutated # quant_error: RGB quantization error to be diffused # -cdef void apply(Dither* dither, int x_res, int y_res, int x, int y, float[:,:,::1] image, float[] quant_error) nogil: +cdef void apply(Dither* dither, int x_res, int y_res, int x, int y, float[:,:,::1] image, float[] quant_error) noexcept nogil: cdef int i, j, k