<commit_before># -*- coding: utf-8 -*-
"""
Test hashing of various supported types.
"""
from __future__ import print_function

import numba.unittest_support as unittest

import sys
from collections import defaultdict

import numpy as np

from numba import jit, types, utils
import numba.unittest_support as unittest
from .support import TestCase, tag, CompilationCache
from numba.targets import hashing

if utils.IS_PY3:
    from numba.unicode import compile_time_get_string_data


def hash_usecase(x):
    return hash(x)


class BaseTest(TestCase):

    def setUp(self):
        self.cfunc = jit(nopython=True)(hash_usecase)

    def check_hash_values(self, values):
        cfunc = self.cfunc
        for val in list(values):
            nb_hash = cfunc(val)
            self.assertIsInstance(nb_hash, utils.INT_TYPES)
            # Always check the value on python 3
            # On python 2, if the input was an integral value, with
            # magnitude < _PyHASH_MODULUS then perform the check
            proceed = utils.IS_PY3
            if not proceed:
                if not isinstance(val, (str, tuple)):
                    intinput = (not np.iscomplexobj(val) and
                                (isinstance(val, utils.INT_TYPES) or
                                 float(val).is_integer()))
                    nonzero = val != 0
                    intmin = val < 0 and abs(val) == val
                    notlong = abs(val) < (hashing._PyHASH_MODULUS)
                    proceed = intinput and nonzero and not intmin and notlong
            if proceed:
                self.assertEqual(nb_hash, hash(val))

    def int_samples(self, typ=np.int64):
        for start in (0, -50, 60000, 1 << 32):
            info = np.iinfo(typ)
            if not info.min <= start <= info.max:
                continue
            n = 100
            yield range(start, start + n)
            yield range(start, start + 100 * n, 100)
            yield range(start, start + 128 * n, 128)
            yield [-1]

    def float_samples(self, typ):
        info = np.finfo(typ)

        for start in (0, 10, info.max ** 0.5, info.max / 1000.0):
            n = 100
            min_step = max(info.tiny, start * info.resolution)
            for step in (1.2, min_step ** 0.5, min_step):
                if step < min_step:
                    continue
                a = np.linspace(start, start + n * step, n)<commit_msg>limit top end of ints for windows<commit_after># -*- coding: utf-8 -*-
"""
Test hashing of various supported types.
"""
from __future__ import print_function

import numba.unittest_support as unittest

import sys
from collections import defaultdict

import numpy as np

from numba import jit, types, utils
import numba.unittest_support as unittest
from .support import TestCase, tag, CompilationCache
from numba.targets import hashing

if utils.IS_PY3:
    from numba.unicode import compile_time_get_string_data


def hash_usecase(x):
    return hash(x)


class BaseTest(TestCase):

    def setUp(self):
        self.cfunc = jit(nopython=True)(hash_usecase)

    def check_hash_values(self, values):
        cfunc = self.cfunc
        for val in list(values):
            nb_hash = cfunc(val)
            self.assertIsInstance(nb_hash, utils.INT_TYPES)
            # Always check the value on python 3
            # On python 2, if the input was an integral value, with
            # magnitude < _PyHASH_MODULUS then perform the check
            proceed = utils.IS_PY3
            if not proceed:
                if not isinstance(val, (str, tuple)):
                    intinput = (not np.iscomplexobj(val) and
                                (isinstance(val, utils.INT_TYPES) or
                                 float(val).is_integer()))
                    nonzero = val != 0
                    intmin = val < 0 and abs(val) == val
                    notlong = abs(val) < (hashing._PyHASH_MODULUS - 1)
                    proceed = intinput and nonzero and not intmin and notlong
            if proceed:
                self.assertEqual(nb_hash, hash(val))

    def int_samples(self, typ=np.int64):
        for start in (0, -50, 60000, 1 << 32):
            info = np.iinfo(typ)
            if not info.min <= start <= info.max:
                continue
            n = 100
            yield range(start, start + n)
            yield range(start, start + 100 * n, 100)
            yield range(start, start + 128 * n, 128)
            yield [-1]

    def float_samples(self, typ):
        info = np.finfo(typ)

        for start in (0, 10, info.max ** 0.5, info.max / 1000.0):
            n = 100
            min_step = max(info.tiny, start * info.resolution)
            for step in (1.2, min_step ** 0.5, min_step):
                if step < min_step:
                    continue
                a = np.linspace(start, start + n * step, n)
{'fraction_non_alphanumeric': 0.088911704312115, 'fraction_numerical': 0.021971252566735114, 'mean_word_length': 1.796211251435132, 'pattern_counts': {'":': 0, '<': 19, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5600960', 'n_tokens_mistral': 1513, 'n_tokens_neox': 1408, 'n_words': 444}