<commit_before># cython: embedsignature=True
# cython: profile=False
# cython: linetrace=False
# cython: binding=False
# cython: language_level=3

import numpy as np
from .compat import ensure_contiguous_ndarray
from .abc import Codec

cimport cython

@cython.boundscheck(False)
@cython.wraparound(False)
cdef void _doShuffle(const unsigned char[::1] src, unsigned char[::1] des, Py_ssize_t element_size) nogil:
    cdef Py_ssize_t count, i, j, offset, byte_index
    count = len(src) // element_size
    for i in range(count):
        offset = i*element_size
        for byte_index in range(element_size):
            j = byte_index*count + i
            des[j] = src[offset + byte_index]


@cython.boundscheck(False)
@cython.wraparound(False)
cdef void _doUnshuffle(const unsigned char[::1] src, unsigned char[::1] des, int element_size) nogil:
    cdef Py_ssize_t count, i, j, offset, byte_index
    count = len(src) // element_size
    for i in range(element_size):
        offset = i*count
        for byte_index in range(count):
            j = byte_index*element_size + i
            des[j] = src[offset+byte_index]


def _shuffle(element_size, buf, out):
    if element_size <= 1:
        out.view(buf.dtype)[:len(buf)] = buf[:]
        return out  # no shuffling needed

    buf_size = buf.nbytes
    if buf_size % element_size != 0:
        raise ValueError("Shuffle buffer is not an integer multiple of elementsize")<commit_msg>Update numcodecs/shuffle.pyx<commit_after># cython: embedsignature=True
# cython: profile=False
# cython: linetrace=False
# cython: binding=False
# cython: language_level=3

import numpy as np
from .compat import ensure_contiguous_ndarray
from .abc import Codec

cimport cython

@cython.boundscheck(False)
@cython.wraparound(False)
cdef void _doShuffle(const unsigned char[::1] src, unsigned char[::1] des, Py_ssize_t element_size) nogil:
    cdef Py_ssize_t count, i, j, offset, byte_index
    count = len(src) // element_size
    for i in range(count):
        offset = i*element_size
        for byte_index in range(element_size):
            j = byte_index*count + i
            des[j] = src[offset + byte_index]


@cython.boundscheck(False)
@cython.wraparound(False)
cdef void _doUnshuffle(const unsigned char[::1] src, unsigned char[::1] des, Py_ssize_t element_size) nogil:
    cdef Py_ssize_t count, i, j, offset, byte_index
    count = len(src) // element_size
    for i in range(element_size):
        offset = i*count
        for byte_index in range(count):
            j = byte_index*element_size + i
            des[j] = src[offset+byte_index]


def _shuffle(element_size, buf, out):
    if element_size <= 1:
        out.view(buf.dtype)[:len(buf)] = buf[:]
        return out  # no shuffling needed

    buf_size = buf.nbytes
    if buf_size % element_size != 0:
        raise ValueError("Shuffle buffer is not an integer multiple of elementsize")
{'fraction_non_alphanumeric': 0.10137931034482758, 'fraction_numerical': 0.004827586206896552, 'mean_word_length': 3.5328125, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1318749', 'n_tokens_mistral': 974, 'n_tokens_neox': 976, 'n_words': 268}