<commit_before>"""Implements the hashids algorithm in python. For more information, visit
http://www.hashids.org/. Compatible with Python 2.5--3"""
from __future__ import division
from math import ceil

__version__ = '1.0.0'

RATIO_SEPARATORS = 3.5
RATIO_GUARDS = 12

# Python 2/3 compatibility code
try:
    StrType = basestring
except NameError:
    StrType = str

# end of compatibility code
def _is_str(candidate):
    """Returns whether a value is a string."""
    return isinstance(candidate, StrType)

def _is_uint(number):
    """Returns whether a value is an unsigned integer."""
    try:
        return number == int(number) and number >= 0
    except ValueError:
        return False

def _split(string, splitters):
    """Splits a string into parts at multiple characters"""
    part = ''
    for character in string:
        if character in splitters:
            yield part
            part = ''
        else:
            part += character
    yield part

def _hash(number, alphabet):
    """Hashes `number` using the given `alphabet` sequence."""
    hashed = ''
    len_alphabet = len(alphabet)
    while True:
        hashed = alphabet[number % len_alphabet] + hashed
        number //= len_alphabet
        if not number:
            return hashed

def _unhash(hashed, alphabet):
    """Restores a number tuple from hashed using the given `alphabet` index."""
    number = 0
    len_hash = len(hashed)
    len_alphabet = len(alphabet)
    for i, character in enumerate(hashed):
        position = alphabet.index(character)
        number += position * len_alphabet ** (len_hash - i - 1)

    return number

def _reorder(string, salt):
    """Reorders `string` according to `salt`."""
    len_salt = len(salt)

    if len_salt == 0:
        return string

    i, index, integer_sum = len(string) - 1, 0, 0
    while i > 0:
        index %= len_salt
        integer = ord(salt[index])
        integer_sum += integer
        j = (integer + index + integer_sum) % i

        temp = string[j]
        trailer = string[j+1:] if j + 1 < len(string) else ''
        string = string[0:j] + string[i] + trailer
        string = string[0:i] + temp + string[i+1:]

        i -= 1
        index += 1

    return string

def _index_from_ratio(dividend, divisor):
    """Returns the ceiled ratio of two numbers as int."""
    return int(ceil(dividend / divisor))

def _ensure_length(encoded, min_length, alphabet, guards, values_hash):
    """Ensures the minimal hash length"""
    len_guards = len(guards)
    guard_index = (values_hash + ord(encoded[0])) % len_guards
    encoded = guards[guard_index] + encoded

    if len(encoded) < min_length:
        guard_index = (values_hash + ord(encoded[2])) % len_guards
        encoded += guards[guard_index]

    split_at = len(alphabet) // 2<commit_msg>Don’t use __future__.division<commit_after>"""Implements the hashids algorithm in python. For more information, visit
http://www.hashids.org/. Compatible with Python 2.5--3"""

from math import ceil

__version__ = '1.0.0'

RATIO_SEPARATORS = 3.5
RATIO_GUARDS = 12

# Python 2/3 compatibility code
try:
    StrType = basestring
except NameError:
    StrType = str

# end of compatibility code
def _is_str(candidate):
    """Returns whether a value is a string."""
    return isinstance(candidate, StrType)

def _is_uint(number):
    """Returns whether a value is an unsigned integer."""
    try:
        return number == int(number) and number >= 0
    except ValueError:
        return False

def _split(string, splitters):
    """Splits a string into parts at multiple characters"""
    part = ''
    for character in string:
        if character in splitters:
            yield part
            part = ''
        else:
            part += character
    yield part

def _hash(number, alphabet):
    """Hashes `number` using the given `alphabet` sequence."""
    hashed = ''
    len_alphabet = len(alphabet)
    while True:
        hashed = alphabet[number % len_alphabet] + hashed
        number //= len_alphabet
        if not number:
            return hashed

def _unhash(hashed, alphabet):
    """Restores a number tuple from hashed using the given `alphabet` index."""
    number = 0
    len_hash = len(hashed)
    len_alphabet = len(alphabet)
    for i, character in enumerate(hashed):
        position = alphabet.index(character)
        number += position * len_alphabet ** (len_hash - i - 1)

    return number

def _reorder(string, salt):
    """Reorders `string` according to `salt`."""
    len_salt = len(salt)

    if len_salt == 0:
        return string

    i, index, integer_sum = len(string) - 1, 0, 0
    while i > 0:
        index %= len_salt
        integer = ord(salt[index])
        integer_sum += integer
        j = (integer + index + integer_sum) % i

        temp = string[j]
        trailer = string[j+1:] if j + 1 < len(string) else ''
        string = string[0:j] + string[i] + trailer
        string = string[0:i] + temp + string[i+1:]

        i -= 1
        index += 1

    return string

def _index_from_ratio(dividend, divisor):
    """Returns the ceiled ratio of two numbers as int."""
    return int(ceil(float(dividend) / divisor))

def _ensure_length(encoded, min_length, alphabet, guards, values_hash):
    """Ensures the minimal hash length"""
    len_guards = len(guards)
    guard_index = (values_hash + ord(encoded[0])) % len_guards
    encoded = guards[guard_index] + encoded

    if len(encoded) < min_length:
        guard_index = (values_hash + ord(encoded[2])) % len_guards
        encoded += guards[guard_index]

    split_at = len(alphabet) // 2
{'fraction_non_alphanumeric': 0.10964285714285714, 'fraction_numerical': 0.010714285714285714, 'mean_word_length': 2.716655607166556, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3037128', 'n_tokens_mistral': 1778, 'n_tokens_neox': 1684, 'n_words': 541}