<commit_before>class Stock(object):
    """ Defines a piece of stock, including planned cuts """

    def __init__(self, length):
        self.pieces = []
        self.length = length
        self.remaining_length = length

<commit_msg>Start fleshing out Stock class<commit_after>class Stock(object):
    """ Defines a piece of stock, including planned cuts """

    def __init__(self, length):
        self.pieces = []
        self.length = length
        self.remaining_length = length

    @property
    def used_length(self):
        return self.length - self.remaining_length

    def cut(self, piece, loss=0.0):
        """ Cut given amount from this stock """
        if (loss + piece.length) > self.remaining_length:
            raise ValueError("Stock too small to cut piece")

        self.pieces.append(piece)
        self.remaining_length -= (loss + piece.length)
        return self.remaining_length

    def shrink(self, new_length):
        """ Attempt to reduce stock size, to minimize waste when possible. """
        if new_length < self.used_length:
            return None

        self.remaining_length = new_length - self.used_length
        self.length = new_length
        return new_length
{'fraction_non_alphanumeric': 0.09390444810543658, 'fraction_numerical': 0.0016474464579901153, 'mean_word_length': 2.5014409221902016, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '3666328', 'n_tokens_mistral': 337, 'n_tokens_neox': 324, 'n_words': 98}