Skip to content

Commit 685fa66

Browse files
committed
fix: Fix rounding bug causing trailing oob values to not fill in when upsampling
1 parent 7202c22 commit 685fa66

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

bbi/cbbi.pyx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,13 +1061,15 @@ cdef inline void array_query_summarized(
10611061

10621062
# Fill output array
10631063
cdef double covFactor = <double>nbins / (end - start)
1064+
cdef double step = (end - start) / nbins
10641065
cdef bbiSummaryElement *el
10651066
cdef double val
1066-
cdef int loc, i
1067+
cdef int bin_start, bin_end, i
10671068
if result:
10681069
for i in range(nbins):
1069-
loc = start + i*stepSize
1070-
if loc < validStart or loc >= validEnd:
1070+
bin_start = start + <int>(<double>i * step)
1071+
bin_end = start + <int>(<double>(i + 1) * step)
1072+
if bin_start < validStart or bin_end > validEnd:
10711073
out[i] = oob
10721074
else:
10731075
el = &elements[i]

0 commit comments

Comments
 (0)