<commit_before>#!/usr/bin/env python3
from collections import namedtuple


class static_property(object):
    """
    Descriptor (non-data) for building an attribute on-demand on first use.
    """

    def __init__(self, factory):
        """
        <factory> is called such: factory(instance) to build the attribute.
        """
        self._attr_name = factory.__name__
        self._factory = factory

    def __get__(self, instance, owner):
        # Build the attribute.
        attr = self._factory(instance)

        # Cache the value; hide ourselves.
        setattr(instance, self._attr_name, attr)

        return attr


# FIXME: define operators
Position = namedtuple("P", ("x", "y"))
P = Position  # Even shorter alias

_Size = namedtuple("Size", ("w", "h"))


class Size(_Size):
    """
    >>> s = Size(2, 3)<commit_msg>utils: Trying to make doctest work static_property.<commit_after>#!/usr/bin/env python3
from collections import namedtuple


class static_property(object):
    """
    Descriptor (non-data) for building an attribute on-demand on first use.
    """

    def __init__(self, factory):
        """
        <factory> is called such: factory(instance) to build the attribute.
        """
        self._attr_name = factory.__name__
        self._factory = factory
        self.__doc__ = factory.__doc__

    def __get__(self, instance, owner):
        if instance is None:
            return self

        # Build the attribute.
        attr = self._factory(instance)

        # Cache the value; hide ourselves.
        setattr(instance, self._attr_name, attr)

        return attr


# FIXME: define operators
Position = namedtuple("P", ("x", "y"))
P = Position  # Even shorter alias

_Size = namedtuple("Size", ("w", "h"))


class Size(_Size):
    """
    >>> s = Size(2, 3)
{'fraction_non_alphanumeric': 0.11966759002770083, 'fraction_numerical': 0.0033240997229916896, 'mean_word_length': 2.6411290322580645, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '1939087', 'n_tokens_mistral': 528, 'n_tokens_neox': 503, 'n_words': 161}