<commit_before># cython: language_level=3
# cython: profile=False

# This file is part of h5py, a Python interface to the HDF5 library.
#
# http://www.h5py.org
#
# Copyright 2008-2019 <NAME> and contributors
#
# License:  Standard 3-clause BSD; see "license.txt" for full license terms
#           and contributor agreement.

from numpy cimport ndarray, import_array,\
                   NPY_UINT16, NPY_UINT32, NPY_UINT64,  npy_intp,\
                   PyArray_SimpleNew, PyArray_ContiguousFromAny,\
                   PyArray_FROM_OTF, PyArray_DIM,\
                   NPY_CONTIGUOUS, NPY_NOTSWAPPED, NPY_FORCECAST

# Initialization
import_array()

# === Exception-aware memory allocation =======================================

cdef inline void* emalloc(size_t size) except? NULL:
    """Wrapper for malloc(size) with the following behavior:

    1. Always returns NULL for emalloc(0)
    2. Raises RuntimeError for emalloc(size<0) and returns NULL
    3. Raises RuntimeError if allocation fails and returns NULL
    """
    cdef void *retval = NULL

    if size == 0:
        return NULL

    retval = malloc(size)
    if retval == NULL:
        errmsg = b"Can't malloc %d bytes" % size
        PyErr_SetString(MemoryError, errmsg)
    return retval

cdef inline void efree(void* what):
    free(what)
<commit_msg>Correct doc-string<commit_after># cython: language_level=3
# cython: profile=False

# This file is part of h5py, a Python interface to the HDF5 library.
#
# http://www.h5py.org
#
# Copyright 2008-2019 <NAME> and contributors
#
# License:  Standard 3-clause BSD; see "license.txt" for full license terms
#           and contributor agreement.

from numpy cimport ndarray, import_array,\
                   NPY_UINT16, NPY_UINT32, NPY_UINT64,  npy_intp,\
                   PyArray_SimpleNew, PyArray_ContiguousFromAny,\
                   PyArray_FROM_OTF, PyArray_DIM,\
                   NPY_CONTIGUOUS, NPY_NOTSWAPPED, NPY_FORCECAST

# Initialization
import_array()

# === Exception-aware memory allocation =======================================

cdef inline void* emalloc(size_t size) except? NULL:
    """Wrapper for malloc(size) with the following behavior:

    1. Always returns NULL for emalloc(0)
    2. Raises MemoryError for emalloc(size<0) and returns NULL
    3. Raises MemoryError if allocation fails and returns NULL
    
    :param size: Size of the memory (in bytes) to allocate
    """
    cdef void *retval = NULL

    if size == 0:
        return NULL

    retval = malloc(size)
    if retval == NULL:
        errmsg = b"Can't malloc %d bytes" % size
        PyErr_SetString(MemoryError, errmsg)
    return retval

cdef inline void efree(void* what):
    free(what)

{'fraction_non_alphanumeric': 0.10897672700406354, 'fraction_numerical': 0.01847063169560399, 'mean_word_length': 3.0059171597633134, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6908834', 'n_tokens_mistral': 865, 'n_tokens_neox': 813, 'n_words': 261}