diff --git a/idr/idr.py b/idr/idr.py index e94d61c..8a8d033 100644 --- a/idr/idr.py +++ b/idr/idr.py @@ -295,8 +295,8 @@ def build_rank_vectors(merged_peaks): rank1 = numpy.lexsort((numpy.random.random(len(s1)), s1)).argsort() rank2 = numpy.lexsort((numpy.random.random(len(s2)), s2)).argsort() - return ( numpy.array(rank1, dtype=numpy.int), - numpy.array(rank2, dtype=numpy.int) ) + return ( numpy.array(rank1, dtype=int), + numpy.array(rank2, dtype=int) ) def build_idr_output_line_with_bed6( m_pk, IDR, localIDR, output_file_type, signal_type, diff --git a/idr/inv_cdf.pyx b/idr/inv_cdf.pyx index a356179..646172b 100644 --- a/idr/inv_cdf.pyx +++ b/idr/inv_cdf.pyx @@ -1,5 +1,6 @@ cimport cython cimport numpy as np +import numpy as np from libc.math cimport exp, sqrt, pow, log, erf, fabs from libc.stdlib cimport malloc, free @@ -67,20 +68,20 @@ def cdf_i(double r, double mu, double sigma, double lamda, @cython.wraparound(False) @cython.cdivision(True) def c_compute_pseudo_values( - np.ndarray[np.int_t, ndim=1] rs, - np.ndarray[np.double_t, ndim=1] zs, + long[:] rs, + double[:] zs, double mu, double sigma, double lamda, double EPS): - cdef int N = len(rs) + cdef int N = rs.shape[0] cdef double pseudo_N = N+1 cdef double* ordered_zs = malloc(N*sizeof(double)) cdef double smallest_r = 1./pseudo_N - lb = d_min(0, mu) + cdef double lb = d_min(0, mu) while c_cdf(lb, mu, sigma, lamda) > smallest_r: lb -= 1 - ub = d_max(0, mu) + cdef double ub = d_max(0, mu) while c_cdf(ub, mu, sigma, lamda) < 1-smallest_r: ub += 1 @@ -101,7 +102,7 @@ def c_compute_pseudo_values( ub = lb + 2*(res - ordered_zs[i-1]) for i in range(N): - zs[i] = ordered_zs[rs[i]] + zs[i] = ordered_zs[rs[i]] free( ordered_zs ) - return zs + return np.asarray(zs)