<commit_before>from nekrobox.docdecs import params


class CardField(object):
    """
    An array of cards of limited size that provides storage.

    provides a list of card slots (None or a card) and the boolean values
    ``full`` and ``overflow``.
    """

    @params(size=(int, "Maximum size of this field"))
    def __init__(self, size):
        self.size = size
        self.cards = [None] * size
        self.full = False
        self.overflow = False

    @params(size=(int, "New maximum size of this field"))
    def change_size(self, size):
        """
        Change field size and recheck ``full`` and ``overflow`` after trimming
        where needed.
        """
        if size > self.size:
            self.cards.extend([None] * (size - self.size))
        elif size < self.size:
            if self.full:
                self.overflow = True

            while size < len(self.cards):
                try:
                    self.cards.remove(None)
                except ValueError:
                    break
        self.size = size

    @params(index=(int, "Index of card to be removed"))
    def remove_card_index(self, index):
        """Remove the card at the given index."""
        if self.overflow:
            self.cards.remove(self.cards[index])
            if self.size == len(self.cards):
                self.overflow = False
        else:
            self.cards[index] = None
            self.full = False

    @params(card=(object, "Card to be removed from this field"))
    def remove_card(self, card):
        """Remove the given card."""
        if self.overflow:
            self.cards.remove(card)
            if self.size == len(self.cards):
                self.overflow = False
        else:
            self.cards[self.cards.index(card)] = None
            self.full = False

    @params(card=(object, "Card to be added to this field"))
    def add_card(self, card):
        """Add the given card."""
        if self.full:
            self.cards.append(card)
            self.overflow = True
        else:
            self.cards[self.cards.index(None)] = card
            self.full = None not in self.cards
<commit_msg>switched carfield to use codes only<commit_after>from nekrobox.docdecs import params


class CardField(object):
    """
    An array of cards of limited size that provides storage.

    provides a list of card slots (None or a card) and the boolean values
    ``full`` and ``overflow``.
    """

    @params(size=(int, "Maximum size of this field"))
    def __init__(self, size):
        self.size = size
        self.cards = [None] * size
        self.full = False
        self.overflow = False

    @params(size=(int, "New maximum size of this field"))
    def change_size(self, size):
        """
        Change field size and recheck ``full`` and ``overflow`` after trimming
        where needed.
        """
        if size > self.size:
            self.cards.extend([None] * (size - self.size))
        elif size < self.size:
            if self.full:
                self.overflow = True

            while size < len(self.cards):
                try:
                    self.cards.remove(None)
                except ValueError:
                    break
        self.size = size

    @params(index=(int, "Index of card to be removed"))
    def remove_card_index(self, index):
        """Remove the card at the given index."""
        if self.overflow:
            self.cards.remove(self.cards[index])
            if self.size == len(self.cards):
                self.overflow = False
        else:
            self.cards[index] = None
            self.full = False

    @params(card=(int, "Card to be removed from this field"))
    def remove_card(self, card):
        """Remove the given card."""
        if self.overflow:
            self.cards.remove(card)
            if self.size == len(self.cards):
                self.overflow = False
        else:
            self.cards[self.cards.index(card)] = None
            self.full = False

    @params(card=(int, "Card to be added to this field"))
    def add_card(self, card):
        """Add the given card."""
        if self.full:
            self.cards.append(card)
            self.overflow = True
        else:
            self.cards[self.cards.index(None)] = card
            self.full = None not in self.cards

{'fraction_non_alphanumeric': 0.11141804788213629, 'fraction_numerical': 0.0, 'mean_word_length': 1.7430555555555556, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4514252', 'n_tokens_mistral': 1194, 'n_tokens_neox': 1167, 'n_words': 369}