<commit_before>from rank_filter cimport lineRankOrderFilter1D_floating_inplace_loop

cimport cython

cimport numpy
import numpy

include "version.pxi"

numpy.import_array()


@cython.boundscheck(False)
def lineRankOrderFilter(numpy.ndarray a not None,
                        size_t half_length,
                        double rank,
                        int axis=-1,
                        numpy.ndarray out=None):
    """
        Runs a linear rank filter kernel along one dimension of an array.

        Args:
            a(numpy.ndarray):          array to run the rank filter over.

            half_length(size_t):       half the window size for the kernel.

            rank(double):              quantile to use from ``0.0`` to ``1.0``.

            axis(int):                 which axis to direct and run the kernel
                                       over defaults to the last one
                                       (e.g. ``-1``).

            out(numpy.ndarray):        where to store the results to. Creates a
                                       new array if not specified. If it is the
                                       same as a, it will run in-place.

        Returns:
            out(numpy.ndarray):        result of running the linear rank filter.
    """

    cdef int a_type_num = numpy.PyArray_TYPE(a)
    cdef int out_type_num

    cdef numpy.ndarray out_swap

    if -a.ndim <= axis < 0:
        axis += a.ndim
    elif not (0 <= axis < a.ndim):
        raise ValueError("`axis` needs to be within `a.ndim`")

    if not ((half_length + 1) <= a.shape[axis]):
        raise ValueError("Window must be no bigger than `a.shape[axis]`.")

    if not (0.0 <= rank <= 1.0):
        raise ValueError("The rank must be between 0.0 and 1.0.")

    if out is None:<commit_msg>Cast `image.shape[axis]` to `size_t` in comparison<commit_after>from rank_filter cimport lineRankOrderFilter1D_floating_inplace_loop

cimport cython

cimport numpy
import numpy

include "version.pxi"

numpy.import_array()


@cython.boundscheck(False)
def lineRankOrderFilter(numpy.ndarray a not None,
                        size_t half_length,
                        double rank,
                        int axis=-1,
                        numpy.ndarray out=None):
    """
        Runs a linear rank filter kernel along one dimension of an array.

        Args:
            a(numpy.ndarray):          array to run the rank filter over.

            half_length(size_t):       half the window size for the kernel.

            rank(double):              quantile to use from ``0.0`` to ``1.0``.

            axis(int):                 which axis to direct and run the kernel
                                       over defaults to the last one
                                       (e.g. ``-1``).

            out(numpy.ndarray):        where to store the results to. Creates a
                                       new array if not specified. If it is the
                                       same as a, it will run in-place.

        Returns:
            out(numpy.ndarray):        result of running the linear rank filter.
    """

    cdef int a_type_num = numpy.PyArray_TYPE(a)
    cdef int out_type_num

    cdef numpy.ndarray out_swap

    if -a.ndim <= axis < 0:
        axis += a.ndim
    elif not (0 <= axis < a.ndim):
        raise ValueError("`axis` needs to be within `a.ndim`")

    if not ((half_length + 1) <= <size_t>(a.shape[axis])):
        raise ValueError("Window must be no bigger than `a.shape[axis]`.")

    if not (0.0 <= rank <= 1.0):
        raise ValueError("The rank must be between 0.0 and 1.0.")

    if out is None:
{'fraction_non_alphanumeric': 0.0860890953812517, 'fraction_numerical': 0.009838753757857338, 'mean_word_length': 1.5293711126468557, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1636302', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1004, 'n_words': 352}