<commit_before>from typing import TypeVar, Dict, Generic, Tuple, Callable

from toolz import dicttoolz  # type: ignore

from tek.tools import find  # type: ignore

from tryp.maybe import may, Maybe
from tryp.list import List

A = TypeVar('A')
B = TypeVar('B')


class Map(Dict[A, B], Generic[A, B]):  # type: ignore

    @staticmethod
    def wrap(d: Dict[A, B]) -> 'Map[A, B]':
        return Map(d)

    @may
    def get(self, key):
        return Dict.get(self, key)

    def __add__(self, item: Tuple[A, B]):
        return Map(dicttoolz.assoc(self, *item))

    def __pow__(self, other: 'Map[A, B]'):
        return Map(dicttoolz.merge(self, other))

    def find(self, f: Callable[[B], bool]) -> Maybe[Tuple[A, B]]:
        return Maybe(find(lambda a: f(self[a]), self.keys_view))\
            .map(lambda k: (k, self[k]))

    def find_key(self, f: Callable[[A], bool]) -> Maybe[Tuple[A, B]]:
        return Maybe(find(f, self.keys_view))\
            .map(lambda k: (k, self[k]))

    @property
    def keys_view(self):
        return Dict.keys(self)

    @property
    def values_view(self):
        return Dict.values(self)

    @property
    def keys(self):
        return List(*Dict.keys(self))

    @property
    def values(self):
        return List(*Dict.values(self))

__all__ = ['Map']
<commit_msg>Map.is_empty<commit_after>from typing import TypeVar, Dict, Generic, Tuple, Callable

from toolz import dicttoolz  # type: ignore

from tek.tools import find  # type: ignore

from tryp.maybe import may, Maybe
from tryp.list import List

A = TypeVar('A')
B = TypeVar('B')


class Map(Dict[A, B], Generic[A, B]):  # type: ignore

    @staticmethod
    def wrap(d: Dict[A, B]) -> 'Map[A, B]':
        return Map(d)

    @may
    def get(self, key):
        return Dict.get(self, key)

    def __add__(self, item: Tuple[A, B]):
        return Map(dicttoolz.assoc(self, *item))

    def __pow__(self, other: 'Map[A, B]'):
        return Map(dicttoolz.merge(self, other))

    def find(self, f: Callable[[B], bool]) -> Maybe[Tuple[A, B]]:
        return Maybe(find(lambda a: f(self[a]), self.keys_view))\
            .map(lambda k: (k, self[k]))

    def find_key(self, f: Callable[[A], bool]) -> Maybe[Tuple[A, B]]:
        return Maybe(find(f, self.keys_view))\
            .map(lambda k: (k, self[k]))

    @property
    def keys_view(self):
        return Dict.keys(self)

    @property
    def values_view(self):
        return Dict.values(self)

    @property
    def keys(self):
        return List(*Dict.keys(self))

    @property
    def values(self):
        return List(*Dict.values(self))

    @property
    def is_empty(self):
        return self.keys.is_empty

__all__ = ['Map']

{'fraction_non_alphanumeric': 0.15358993338267948, 'fraction_numerical': 0.0, 'mean_word_length': 2.828611898016997, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1486525', 'n_tokens_mistral': 973, 'n_tokens_neox': 941, 'n_words': 253}