<commit_before>
# cython: boundscheck=True
# cython: wraparound=False
# cython: embedsignature=True
# cython: cdivision=True
# cython: profile=True
import cython
import numpy as np
cimport numpy as np
#from cython.parallel import prange
from math import fabs
DTYPE = np.float64
ctypedef np.float64_t DTYPE_t


cdef inline DTYPE_t dabs(DTYPE_t x) nogil: 
    return x if x >= 0 else -x 

cdef inline DTYPE_t lerp(DTYPE_t a, DTYPE_t x, DTYPE_t y) nogil:
    return (1.0-a) * x + a * y

def interp2d(np.ndarray[DTYPE_t, ndim=2] x, np.ndarray[DTYPE_t, ndim=2] y, z, dx=None, startx=None, fill_value=None): 
    """
    Calculates bilinear interpolated points of ``z`` at positions ``x`` and ``y``.
    
    The motivation of this function is that ``scipy.interpolate.interp2d(..., kind='linear')`` produces unwanted results.

    Parameters
    ----------
    x, y : ndarray
        Points at which to interpolate data. Array of shape ``(A, B)``, where ``A`` and ``B`` are the rows and columns.
    z : ndarray
        The original array that should be interpolated. Array of size ``(cols, rows)``.
    dx : ndarray or None
        The distance between points in ``z``. Array of size 2.
        If None, even spacing that range from 0.0 to 1.0 is assumed.
    startx : ndarray or None
        The ``(x, y)`` value corresponding to ``z[0,0]``. Array of size 2. 
    fill_value : float or None
        The value to return outside the area specified by ``z``. If None, the closest value inside the area is used.

    Returns
    -------
    output : ndarray
        Array of shape ``(A, B)`` with interpolated values at positions at ``x`` and ``y``.
    """
    
    assert(x.dtype == DTYPE)
    assert(y.dtype == DTYPE)
    assert(z.dtype == DTYPE)
    assert(x.shape == y.shape, "x and y must be the same shape")
    dx = dx if dx is not None else 1.0/(np.array(z.shape))
    startx = startx if startx is not None else np.zeros(2) 

    cdef:
        DTYPE_t startx0 = startx[0]
        DTYPE_t startx1 = startx[1]
        DTYPE_t dx0 = dx[0]
        DTYPE_t dx1 = dx[1]
<commit_msg>DOC: Fixed typo.<commit_after>
# cython: boundscheck=True
# cython: wraparound=False
# cython: embedsignature=True
# cython: cdivision=True
# cython: profile=True
import cython
import numpy as np
cimport numpy as np
#from cython.parallel import prange
from math import fabs
DTYPE = np.float64
ctypedef np.float64_t DTYPE_t


cdef inline DTYPE_t dabs(DTYPE_t x) nogil: 
    return x if x >= 0 else -x 

cdef inline DTYPE_t lerp(DTYPE_t a, DTYPE_t x, DTYPE_t y) nogil:
    return (1.0-a) * x + a * y

def interp2d(np.ndarray[DTYPE_t, ndim=2] x, np.ndarray[DTYPE_t, ndim=2] y, z, dx=None, startx=None, fill_value=None): 
    """
    Calculates bilinear interpolated points of ``z`` at positions ``x`` and ``y``.
    
    The motivation of this function is that ``scipy.interpolate.interp2d(..., kind='linear')`` produces unwanted results.

    Parameters
    ----------
    x, y : ndarray
        Points at which to interpolate data. Array of shape ``(A, B)``, where ``A`` and ``B`` are the rows and columns.
    z : ndarray
        The original array that should be interpolated. Array of size ``(A, B)``.
    dx : ndarray or None
        The distance between points in ``z``. Array of size 2.
        If None, even spacing that range from 0.0 to 1.0 is assumed.
    startx : ndarray or None
        The ``(x, y)`` value corresponding to ``z[0,0]``. Array of size 2. 
    fill_value : float or None
        The value to return outside the area specified by ``z``. If None, the closest value inside the area is used.

    Returns
    -------
    output : ndarray
        Array of shape ``(A, B)`` with interpolated values at positions at ``x`` and ``y``.
    """
    
    assert(x.dtype == DTYPE)
    assert(y.dtype == DTYPE)
    assert(z.dtype == DTYPE)
    assert(x.shape == y.shape, "x and y must be the same shape")
    dx = dx if dx is not None else 1.0/(np.array(z.shape))
    startx = startx if startx is not None else np.zeros(2) 

    cdef:
        DTYPE_t startx0 = startx[0]
        DTYPE_t startx1 = startx[1]
        DTYPE_t dx0 = dx[0]
        DTYPE_t dx1 = dx[1]

{'fraction_non_alphanumeric': 0.1194317360943896, 'fraction_numerical': 0.014447387430772935, 'mean_word_length': 2.755877034358047, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3279126', 'n_tokens_mistral': 1471, 'n_tokens_neox': 1424, 'n_words': 528}