Add specific branch for the percentile p0 = 0 case

This commit is contained in:
Johannes Schönberger
2013-07-31 19:24:18 +02:00
parent 5c5c67027e
commit 391e976157
+9 -5
View File
@@ -161,11 +161,15 @@ cdef inline double _kernel_percentile(Py_ssize_t* histo, double pop, dtype_t g,
cdef Py_ssize_t sum = 0
if pop:
for i in range(max_bin):
sum += histo[i]
if sum >= p0 * pop:
break
if p0 == 0: # make sure p0 == 0 returns the minimum filter
for i in range(max_bin):
if histo[i]:
break
else:
for i in range(max_bin):
sum += histo[i]
if sum >= p0 * pop:
break
return i
else:
return 0