<commit_before>cimport cython
from cython cimport floating

cimport numpy


cdef extern from "rank_filter.hxx" namespace "rank_filter":
    void lineRankOrderFilter1D[I1, I2](const I1& src_begin,
                                       const I1& src_end,
                                       I2& dest_begin,
                                       I2& dest_end,
                                       size_t half_length,
                                       double rank) nogil


@cython.boundscheck(False)
@cython.initializedcheck(False)
@cython.nonecheck(False)
cdef inline void lineRankOrderFilter1D_floating_inplace(floating* a_begin,
                                                        size_t a_len,
                                                        size_t half_length,
                                                        double rank) nogil:
    cdef floating* a_end = a_begin + a_len

    lineRankOrderFilter1D(
        a_begin, a_end, a_begin, a_end, half_length, rank
    )


@cython.boundscheck(False)
@cython.initializedcheck(False)
@cython.nonecheck(False)
cdef inline void lineRankOrderFilter1D_floating_inplace_loop(floating* out_data,
                                                             numpy.npy_intp out_size,
                                                             numpy.npy_intp out_step,
                                                             size_t half_length,
                                                             double rank) nogil:
    cdef numpy.npy_intp i

    cdef floating* out_ptr = out_data
    for i from 0 <= i < out_size by out_step:
        lineRankOrderFilter1D_floating_inplace[floating](
            out_ptr, out_step, half_length, rank
        )
        out_ptr += out_step
<commit_msg>Call C++ function directly from looped filter func<commit_after>cimport cython
from cython cimport floating

cimport numpy


cdef extern from "rank_filter.hxx" namespace "rank_filter":
    void lineRankOrderFilter1D[I1, I2](const I1& src_begin,
                                       const I1& src_end,
                                       I2& dest_begin,
                                       I2& dest_end,
                                       size_t half_length,
                                       double rank) nogil


@cython.boundscheck(False)
@cython.initializedcheck(False)
@cython.nonecheck(False)
cdef inline void lineRankOrderFilter1D_floating_inplace(floating* a_begin,
                                                        size_t a_len,
                                                        size_t half_length,
                                                        double rank) nogil:
    cdef floating* a_end = a_begin + a_len

    lineRankOrderFilter1D(
        a_begin, a_end, a_begin, a_end, half_length, rank
    )


@cython.boundscheck(False)
@cython.initializedcheck(False)
@cython.nonecheck(False)
cdef inline void lineRankOrderFilter1D_floating_inplace_loop(floating* out_data,
                                                             numpy.npy_intp out_size,
                                                             numpy.npy_intp out_step,
                                                             size_t half_length,
                                                             double rank) nogil:
    cdef numpy.npy_intp i

    cdef floating* out_begin = out_data
    cdef floating* out_end = out_data + out_step
    for i from 0 <= i < out_size by out_step:
        lineRankOrderFilter1D(
            out_begin, out_end, out_begin, out_end, half_length, rank
        )
        out_begin += out_step
        out_end += out_step

{'fraction_non_alphanumeric': 0.0513172338090011, 'fraction_numerical': 0.006586169045005488, 'mean_word_length': 1.2252747252747254, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 42, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6137003', 'n_tokens_mistral': 933, 'n_tokens_neox': 908, 'n_words': 210}