Skip to content

Commit

Permalink
0.0.63
Browse files Browse the repository at this point in the history
  • Loading branch information
endre bakken stovner authored and endre bakken stovner committed Oct 18, 2021
1 parent c871f14 commit a2f9eb3
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 95 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.0.63 (18.10.21)
- fix critical error: fix 1024-error for subtract 64 bit

# 0.0.62 (20.09.21)
- fix critical error: fix 1024-error for subtract

# 0.0.61 (13.09.21)
- fix critical error: in case of more than 1024 overlaps for on interval only reported 1024 first

Expand Down
97 changes: 37 additions & 60 deletions ncls/src/ncls.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,8 @@ cdef class NCLS64:
@cython.boundscheck(False)
@cython.wraparound(False)
@cython.initializedcheck(False)
cpdef set_difference_helper(self, const int64_t [::1] starts, const int64_t [::1] ends, const int64_t [::1] indexes):
cpdef set_difference_helper(self, const int64_t [::1] starts, const int64_t [::1] ends, const int64_t [::1] indexes, const int64_t [::1] nhits,
const int64_t[::1] nhits):

cdef int i
cdef int nhit = 0
Expand Down Expand Up @@ -477,28 +478,21 @@ cdef class NCLS64:
if not self.im: # if empty
return [], [], []


it_alloc = cn.interval_iterator_alloc()
it = it_alloc
for loop_counter in range(length):

spent = 0
while it:
nhit = nhits[loop_counter]
nstart = starts[loop_counter]
nend = ends[loop_counter]

while nhit > 0:
i = 0
cn.find_intervals(it, starts[loop_counter], ends[loop_counter], self.im, self.ntop,
self.subheader, self.nlists, im_buf, 1024,
&(nhit), &(it)) # GET NEXT BUFFER CHUNK

#print("nhits:", nhit)

nstart = starts[loop_counter]
nend = ends[loop_counter]

# print("nstart", nstart)
# print("nend", nend)
&(na), &(it)) # GET NEXT BUFFER CHUNK

if nfound + nhit >= length:

length = (length + nhit) * 2
output_arr = np.resize(output_arr, length)
output_arr_start = np.resize(output_arr_start, length)
Expand All @@ -515,62 +509,45 @@ cdef class NCLS64:
output[nfound] = indexes[loop_counter]
i = nhit
nfound += 1
break

while i < nhit:
# print("--- i:", i)
# print("--- im_buf[i]", im_buf[i])
#print(" B start:", im_buf[i].start)
#print(" B end:", im_buf[i].end)
max_i = 1024 if nhit > 1024 else nhit

while i < max_i:
# in case the start contributes nothing
if i < nhit - 1:
# print(" i < nhit - 1")
if nstart < im_buf[i].start:
output[nfound] = indexes[loop_counter]
output_start[nfound] = nstart
output_end[nfound] = im_buf[i].start
nfound += 1
nstart = im_buf[i].end

if nstart < im_buf[i].start:
#print(" new_start", nstart)
#print(" new_end", im_buf[i].start)
i += 1

nhit = nhit - 1024

if nhit <= 0:
i = i - 1
if im_buf[i].start <= nstart and im_buf[i].end >= ends[loop_counter]:
# print("im_buf[i].start <= nstart and im_buf[i].end >= ends[loop_counter]")
#print("we are here " * 10)

output_start[nfound] = -1
output_end[nfound] = -1
output[nfound] = <long> indexes[loop_counter]
nfound += 1
else:
if im_buf[i].start > nstart:
output[nfound] = indexes[loop_counter]
output_start[nfound] = nstart
output_end[nfound] = im_buf[i].start
nfound += 1

nstart = im_buf[i].end
elif i == nhit - 1:

# print("i == nhit -1")
#print("im_buf[i].start", im_buf[i].start)
#print("im_buf[i].end", im_buf[i].end)
#print("nstart", nstart)
#print("ends[loop_counter]", ends[loop_counter])

if im_buf[i].start <= nstart and im_buf[i].end >= ends[loop_counter]:
# print("im_buf[i].start <= nstart and im_buf[i].end >= ends[loop_counter]")
#print("we are here " * 10)

output_start[nfound] = -1
output_end[nfound] = -1
output[nfound] = <long> indexes[loop_counter]
if im_buf[i].end < ends[loop_counter]:
output[nfound] = indexes[loop_counter]
output_start[nfound] = im_buf[i].end
output_end[nfound] = ends[loop_counter]
nfound += 1
else:
if im_buf[i].start > nstart:
# print("im_buf[i].start > nstart", im_buf[i].start, nstart)
output[nfound] = indexes[loop_counter]
output_start[nfound] = nstart
output_end[nfound] = im_buf[i].start
nfound += 1

if im_buf[i].end < ends[loop_counter]:
# print("im_buf[i].end < ends[loop_counter]", im_buf[i].end, ends[loop_counter])
# print("i, loop_counter", i, loop_counter)
# print("indexes[loop_counter]", indexes[loop_counter])
# print("indexes", indexes[loop_counte rloop_counter])

output[nfound] = indexes[loop_counter]
output_start[nfound] = im_buf[i].end
output_end[nfound] = ends[loop_counter]
nfound += 1

i += 1

cn.reset_interval_iterator(it_alloc)
it = it_alloc
Expand Down
69 changes: 35 additions & 34 deletions ncls/src/ncls32.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -478,14 +478,13 @@ cdef class NCLS32:
cdef int i = 0
cdef int nhit = 0
cdef int nfound = 0
cdef int nfound_loop = 0
cdef int32_t nstart = 0
cdef int32_t nend = 0
cdef int length = len(starts)
cdef int loop_counter = 0
cdef int overlap_type_nb = 0
cdef int na = -1
cdef int spent = 0
cdef int max_i = 0

output_arr = np.zeros(length, dtype=np.int64)
output_arr_start = np.zeros(length, dtype=np.int32)
Expand All @@ -512,10 +511,8 @@ cdef class NCLS32:
nhit = nhits[loop_counter]
nstart = starts[loop_counter]
nend = ends[loop_counter]
nfound_loop = 0
spent = 0

while not spent:
while nhit > 0:
i = 0
cn.find_intervals(it, starts[loop_counter], ends[loop_counter], self.im, self.ntop,
self.subheader, self.nlists, im_buf, 1024,
Expand All @@ -538,42 +535,46 @@ cdef class NCLS32:
output[nfound] = indexes[loop_counter]
i = nhit
nfound += 1
nfound_loop += 1
break

while i < 1024:
max_i = 1024 if nhit > 1024 else nhit

while i < max_i:
# in case the start contributes nothing
if i < nhit - 1:
if nstart < im_buf[i].start:
if nstart < im_buf[i].start:
output[nfound] = indexes[loop_counter]
output_start[nfound] = nstart
output_end[nfound] = im_buf[i].start
nfound += 1
nstart = im_buf[i].end

i += 1

nhit = nhit - 1024

if nhit <= 0:
i = i - 1

if im_buf[i].start <= nstart and im_buf[i].end >= ends[loop_counter]:
# print("im_buf[i].start <= nstart and im_buf[i].end >= ends[loop_counter]")
#print("we are here " * 10)

output_start[nfound] = -1
output_end[nfound] = -1
output[nfound] = <long> indexes[loop_counter]
nfound += 1
else:
if im_buf[i].start > nstart:
output[nfound] = indexes[loop_counter]
output_start[nfound] = nstart
output_end[nfound] = im_buf[i].start
nfound += 1
nfound_loop += 1

nstart = im_buf[i].end
elif nfound_loop == nhit - 1:
if im_buf[i].start <= nstart and im_buf[i].end >= ends[loop_counter]:
output_start[nfound] = -1
output_end[nfound] = -1
output[nfound] = <long> indexes[loop_counter]
nfound += 1
nfound_loop += 1
else:
if im_buf[i].start > nstart:
output[nfound] = indexes[loop_counter]
output_start[nfound] = nstart
output_end[nfound] = im_buf[i].start
nfound += 1
nfound_loop += 1

if im_buf[i].end < ends[loop_counter]:
output[nfound] = indexes[loop_counter]
output_start[nfound] = im_buf[i].end
output_end[nfound] = ends[loop_counter]
nfound += 1
nfound_loop += 1

i += 1
if im_buf[i].end < ends[loop_counter]:
output[nfound] = indexes[loop_counter]
output_start[nfound] = im_buf[i].end
output_end[nfound] = ends[loop_counter]
nfound += 1

cn.reset_interval_iterator(it_alloc)
it = it_alloc
Expand Down
2 changes: 1 addition & 1 deletion ncls/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.61"
__version__ = "0.0.63"

0 comments on commit a2f9eb3

Please sign in to comment.