Skip to content

Commit 2b6b0ae

Browse files
author
Edgar Gutierrez Fernandez
committed
Merge remote-tracking branch 'origin/main' into fiberunits_deepcopy
2 parents 06622cf + 17936e4 commit 2b6b0ae

File tree

4 files changed

+19
-26
lines changed

4 files changed

+19
-26
lines changed

src/pyFAI/ext/bilinear.pxi

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,12 @@ cdef class Bilinear:
117117

118118
cdef:
119119
int i0, i1, j0, j1
120-
float x0, x1, y0, y1, res
121-
if d0 < 0:
122-
d0 = 0
123-
elif d1 < 0:
124-
d1 = 0
125-
elif d0 > (self.height - 1):
126-
d0 = self.height - 1
127-
elif d1 > self.width - 1:
128-
d1 = self.width - 1
120+
float x0, x1, y0, y1, res,
121+
floating d0max, d1max
122+
d0max = self.height - 1.0
123+
d1max = self.width - 1.0
124+
d0 = max(min(d0, d0max), 0.0)
125+
d1 = max(min(d1, d1max), 0.0)
129126
x0 = floor(d0)
130127
x1 = ceil(d0)
131128
y0 = floor(d1)

src/pyFAI/ext/inpainting.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
Cython module for doing inpaining of images.
3333
"""
3434
__author__ = "Jérôme Kieffer"
35-
__date__ = "09/03/2023"
35+
__date__ = "12/11/2024"
3636
__contact__ = "[email protected]"
3737
__license__ = "MIT"
3838

@@ -139,10 +139,10 @@ def polar_inpaint(floating[:, :] img not None,
139139
:return: image with missing values interpolated from neighbors.
140140
"""
141141
cdef:
142-
int row, col, npt_radial, npt_azim, idx_col, idx_row, tar_row, radius
142+
int row, col, npt_radial, npt_azim, idx_col, idx_row, tar_row, radius, dist
143143
float[:, ::1] res
144144
bint do_dummy = empty is not None
145-
float value, dummy, dist
145+
float value, dummy
146146
double sum, cnt, weight
147147
list values
148148

src/pyFAI/ext/reconstruct.pyx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ image (masked) to be able to use more common algorithms.
3737

3838
__author__ = "Jerome Kieffer"
3939
__contact__ = "[email protected]"
40-
__date__ = "03/03/2023"
40+
__date__ = "12/11/2024"
4141
__status__ = "stable"
4242
__license__ = "MIT"
4343

4444

4545
import cython
4646
import numpy
47-
from libc.math cimport sqrt, fabs, NAN
47+
from libc.math cimport sqrtf, fabs, NAN
4848
from cython.parallel import prange
4949
from libc.stdint cimport int8_t, uint8_t, int16_t, uint16_t, \
5050
int32_t, uint32_t, int64_t, uint64_t
@@ -55,11 +55,7 @@ cdef inline float invert_distance(Py_ssize_t i0, Py_ssize_t i1, Py_ssize_t p0, P
5555
cdef Py_ssize_t d0, d1
5656
d0 = (i0 - p0)
5757
d1 = (i1 - p1)
58-
return 1. / sqrt(d0*d0 + d1*d1)
59-
# if d0*d1:
60-
# else:
61-
# return NAN
62-
58+
return (<float> 1.0) / sqrtf(<float> (d0*d0 + d1*d1))
6359

6460
cdef inline float processPoint(float[:, ::1] data,
6561
int8_t[:, ::1] mask,

src/pyFAI/ext/regrid_common.pxi

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Some are defined in the associated header file .pxd
3232

3333
__author__ = "Jérôme Kieffer"
3434
__contact__ = "[email protected]"
35-
__date__ = "24/04/2024"
35+
__date__ = "12/11/2024"
3636
__status__ = "stable"
3737
__license__ = "MIT"
3838

@@ -490,14 +490,14 @@ cdef inline void _integrate1d(buffer_t[::1] buffer,
490490
if 0 <= start0 < buffer_size:
491491
buffer[istart0] += _calc_area(start0, floor(start0 + 1), slope, intercept)
492492
for i in range(max(istart0 + 1, 0), min(istop0, buffer_size)):
493-
buffer[i] += _calc_area(i, i + 1, slope, intercept)
493+
buffer[i] += _calc_area(<floating>i, <floating>(i + 1), slope, intercept)
494494
if buffer_size > stop0 >= 0:
495-
buffer[istop0] += _calc_area(istop0, stop0, slope, intercept)
495+
buffer[istop0] += _calc_area(<floating> istop0, stop0, slope, intercept)
496496
else:
497497
if 0 <= start0 < buffer_size:
498-
buffer[istart0] += _calc_area(start0, istart0, slope, intercept)
498+
buffer[istart0] += _calc_area(start0, <floating> istart0, slope, intercept)
499499
for i in range(min(istart0, buffer_size) - 1, max(<Py_ssize_t> floor(stop0), -1), -1):
500-
buffer[i] += _calc_area(i + 1, i, slope, intercept)
500+
buffer[i] += _calc_area(<floating>(i + 1), <floating>i, slope, intercept)
501501
if buffer_size > stop0 >= 0:
502502
buffer[istop0] += _calc_area(floor(stop0 + 1), stop0, slope, intercept)
503503

@@ -562,7 +562,7 @@ cdef inline void _integrate2d(buffer_t[:, ::1] box,
562562
h += 1
563563
# subsection P1->Pn
564564
for i in range((<Py_ssize_t> floor(P)), (<Py_ssize_t> floor(stop0))):
565-
segment_area = _calc_area(i, i + 1, slope, intercept)
565+
segment_area = _calc_area(<floating> i, <floating> (i + 1), slope, intercept)
566566
if segment_area != 0:
567567
abs_area = fabs(segment_area)
568568
h = 0
@@ -623,7 +623,7 @@ cdef inline void _integrate2d(buffer_t[:, ::1] box,
623623
h += 1
624624
# subsection P1->Pn
625625
for i in range((<Py_ssize_t> start0), (<Py_ssize_t> ceil(stop0)), -1):
626-
segment_area = _calc_area(i, i - 1, slope, intercept)
626+
segment_area = _calc_area(<floating> i, <floating> (i - 1), slope, intercept)
627627
if segment_area != 0:
628628
abs_area = fabs(segment_area)
629629
h = 0

0 commit comments

Comments
 (0)