forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
release GIL on is_lexsorted / fix memory leak release GIL on nancorr
- Loading branch information
Showing
5 changed files
with
123 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,13 @@ | ||
from util cimport numeric | ||
from numpy cimport float64_t, double_t | ||
|
||
cpdef numeric kth_smallest(numeric[:] a, Py_ssize_t k) | ||
cpdef numeric kth_smallest(numeric[:] a, Py_ssize_t k) nogil | ||
|
||
cdef inline Py_ssize_t swap(numeric *a, numeric *b) nogil except -1: | ||
cdef inline Py_ssize_t swap(numeric *a, numeric *b) nogil: | ||
cdef numeric t | ||
|
||
# cython doesn't allow pointer dereference so use array syntax | ||
t = a[0] | ||
a[0] = b[0] | ||
b[0] = t | ||
return 0 | ||
|
||
|
||
cdef inline kth_smallest_c(float64_t* a, Py_ssize_t k, Py_ssize_t n): | ||
cdef: | ||
Py_ssize_t i, j, l, m | ||
double_t x, t | ||
|
||
l = 0 | ||
m = n -1 | ||
while (l<m): | ||
x = a[k] | ||
i = l | ||
j = m | ||
|
||
while 1: | ||
while a[i] < x: i += 1 | ||
while x < a[j]: j -= 1 | ||
if i <= j: | ||
swap(&a[i], &a[j]) | ||
i += 1; j -= 1 | ||
|
||
if i > j: break | ||
|
||
if j < k: l = i | ||
if k < i: m = j | ||
return a[k] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.