<commit_before>from typing import Callable, List, Union

import numpy as np
from hypothesis.extra.numpy import array_shapes
from hypothesis.extra.numpy import arrays as hy_arrays
from hypothesis.extra.numpy import floating_dtypes, integer_dtypes
from hypothesis.strategies import one_of

import bottleneck as bn

INT_DTYPES = [np.int64, np.int32]
FLOAT_DTYPES = [np.float64, np.float32]
DTYPES = tuple(FLOAT_DTYPES + INT_DTYPES)


hy_array_gen = hy_arrays(
    dtype=one_of(integer_dtypes(sizes=(32, 64)), floating_dtypes(sizes=(32, 64))),
    shape=array_shapes(),
)


def get_functions(module_name, as_string=False):
    """Returns a list of functions, optionally as string function names"""
    if module_name == "all":
        funcs = []
        funcs_in_dict = func_dict()
        for key in funcs_in_dict:
            for func in funcs_in_dict[key]:
                funcs.append(func)
    else:
        funcs = func_dict()[module_name]
    if as_string:
        funcs = [f.__name__ for f in funcs]
    return funcs


def func_dict():
    d = {}
    d["reduce"] = [
        bn.nansum,
        bn.nanmean,
        bn.nanstd,
        bn.nanvar,
        bn.nanmin,
        bn.nanmax,
        bn.median,<commit_msg>TYP: add annotation in tests/util.py<commit_after>from typing import Callable, List, Union

import numpy as np
from hypothesis.extra.numpy import array_shapes, floating_dtypes, integer_dtypes
from hypothesis.extra.numpy import arrays as hy_arrays
from hypothesis.strategies import one_of

import bottleneck as bn

INT_DTYPES = [np.int64, np.int32]
FLOAT_DTYPES = [np.float64, np.float32]
DTYPES = tuple(FLOAT_DTYPES + INT_DTYPES)


hy_array_gen = hy_arrays(
    dtype=one_of(integer_dtypes(sizes=(32, 64)), floating_dtypes(sizes=(32, 64))),
    shape=array_shapes(),
)

hy_int_array_gen = hy_arrays(
    dtype=integer_dtypes(sizes=(32, 64)), shape=array_shapes(),
)


def get_functions(
    module_name: str, as_string: bool = False
) -> List[Union[str, Callable[[np.array], Union[int, float, np.array]]]]:
    """Returns a list of functions, optionally as string function names"""
    if module_name == "all":
        funcs = []
        funcs_in_dict = func_dict()
        for key in funcs_in_dict:
            for func in funcs_in_dict[key]:
                funcs.append(func)
    else:
        funcs = func_dict()[module_name]
    if as_string:
        funcs = [f.__name__ for f in funcs]
    return funcs


def func_dict():
    d = {}
    d["reduce"] = [
        bn.nansum,
        bn.nanmean,
        bn.nanstd,
        bn.nanvar,
        bn.nanmin,
        bn.nanmax,
        bn.median,
{'fraction_non_alphanumeric': 0.10621165644171779, 'fraction_numerical': 0.013803680981595092, 'mean_word_length': 3.057542768273717, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 4, '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': '5158267', 'n_tokens_mistral': 950, 'n_tokens_neox': 895, 'n_words': 216}