<commit_before>import warnings

from functools import wraps

from astropy.utils.exceptions import AstropyUserWarning

def cached(func):
    """
    Decorator to cache function calls
    """

    @wraps(func)
    def wrapper(self, *args):
        # The cache lives in the instance so that it gets garbage collected
        if (func, args) not in self._cache:
            self._cache[(func, args)] = func(self, *args)
        return self._cache[(func, args)]

    wrapper.wrapped_function = func

    return wrapper

def warn_slow(function):

    @wraps(function)
    def wrapper(self, *args, **kwargs):
        # if the function accepts a 'how', the 'cube' approach requires the whole cube in memory
        warn_how = ('how' in kwargs and kwargs['how'] == 'cube') or 'how' not in kwargs
        if self._is_huge and not self.allow_huge_operations and warn_how:
            raise ValueError("This function ({0}) requires loading the entire "
                             "cube into memory, and the cube is large ({1} "<commit_msg>implement @e-koch's suggestion (approximately - 'how' not in kwargs is not identical to kwargs['how'] == None)<commit_after>import warnings

from functools import wraps

from astropy.utils.exceptions import AstropyUserWarning

def cached(func):
    """
    Decorator to cache function calls
    """

    @wraps(func)
    def wrapper(self, *args):
        # The cache lives in the instance so that it gets garbage collected
        if (func, args) not in self._cache:
            self._cache[(func, args)] = func(self, *args)
        return self._cache[(func, args)]

    wrapper.wrapped_function = func

    return wrapper

def warn_slow(function):

    @wraps(function)
    def wrapper(self, *args, **kwargs):
        # if the function accepts a 'how', the 'cube' approach requires the whole cube in memory
        warn_how = (kwargs.get('how') == 'cube') or 'how' not in kwargs
        if self._is_huge and not self.allow_huge_operations and warn_how:
            raise ValueError("This function ({0}) requires loading the entire "
                             "cube into memory, and the cube is large ({1} "
{'fraction_non_alphanumeric': 0.09770920991117345, 'fraction_numerical': 0.0018700327255726976, 'mean_word_length': 2.855855855855856, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2845802', 'n_tokens_mistral': 609, 'n_tokens_neox': 601, 'n_words': 225}