<commit_before>"""A number of utility functions."""

from random import random, randrange
from collections import defaultdict
from bisect import bisect
import inspect

import pygame as pg
from pygame import Rect

# be sure to change util.rst
__all__ = ('dd', 'takes_args', 'wrap_fn', 'ir', 'sum_pos', 'pos_in_rect',
           'normalise_colour', 'randsgn','rand0', 'weighted_rand',
           'align_rect', 'position_sfc', 'convert_sfc', 'combine_drawn',
           'blank_sfc', 'Grid', 'InfiniteGrid')


# abstract


def dd (default, items = {}, **kwargs):
    """Create a ``collections.defaultdict`` with a static default.

dd(default[, items], **kwargs) -> default_dict

:arg default: the default value.
:arg items: dict or dict-like to initialise with.
:arg kwargs: extra items to initialise with.

:return: the created ``defaultdict``.

"""
    items.update(kwargs)
    return defaultdict(lambda: default, items)


def takes_args (func):
    """Determine whether the given function takes any arguments.<commit_msg>util.dd copies passed items to avoid object sharing<commit_after>"""A number of utility functions."""

from random import random, randrange
from collections import defaultdict
from bisect import bisect
import inspect

import pygame as pg
from pygame import Rect

# be sure to change util.rst
__all__ = ('dd', 'takes_args', 'wrap_fn', 'ir', 'sum_pos', 'pos_in_rect',
           'normalise_colour', 'randsgn','rand0', 'weighted_rand',
           'align_rect', 'position_sfc', 'convert_sfc', 'combine_drawn',
           'blank_sfc', 'Grid', 'InfiniteGrid')


# abstract


def dd (default, items = {}, **kwargs):
    """Create a ``collections.defaultdict`` with a static default.

dd(default[, items], **kwargs) -> default_dict

:arg default: the default value.
:arg items: dict or dict-like to initialise with.
:arg kwargs: extra items to initialise with.

:return: the created ``defaultdict``.

"""
    items = items.copy()
    items.update(kwargs)
    return defaultdict(lambda: default, items)


def takes_args (func):
    """Determine whether the given function takes any arguments.
{'fraction_non_alphanumeric': 0.12601046124583928, 'fraction_numerical': 0.0009510223490252021, 'mean_word_length': 4.381074168797954, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1635190', 'n_tokens_mistral': 639, 'n_tokens_neox': 620, 'n_words': 222}