<commit_before>import curses
import copy

class Shape(object):

    def __init__(self, shape_def, shape_name, shape_char):
        """ The shape_def is a list of 5 numbers.
        Each number defines one line in the 5x5
        shape table matrix.  The base two representation
        of the number defines if a pixel is on or off.
        """
        self.shape_table = []
        self.transformation = []
        self.shape_dim = len(shape_def)
        self.shape_name = shape_name
        self.shape_char = shape_char
        self.transform_num = 0

        # Create shape_table from the shape_def.
        # shape_table is a list of lists.
        # The 1st dimension specifies the line (row).
        # The 2nd dimension specifies the pixel in the line (column).
        # (0,0) is the upper left corner.
        # A value of 1 indicates the pixel is set.
        # A value of 0 indicates the pixel is not set.
        for line in shape_def:
            line_list = []
            mask = 0x01
            for i in range(self.shape_dim):
                if line & mask:
                    line_list.append(1)
                else:
                    line_list.append(0)
                line = line >> 1
            line_list.reverse()
            self.shape_table.append(line_list)

        # Initialize the transformation list
        self._init_transformation()

    def _init_transformation(self):
        trans = self.shape_table

        # Check the 4 non reflective rotations
        for i in range(4):
            next_trans = self._rotate_cw(trans)
            if not self._already_in_transformation(next_trans):
                self.transformation.append(next_trans)
            trans = next_trans

        # Check the 4 reflective rotations
        trans = self._reflect(self.shape_table)
        for i in range(4):
            next_trans = self._rotate_cw(trans)
            if not self._already_in_transformation(next_trans):
                self.transformation.append(next_trans)
            trans = next_trans

    def _already_in_transformation(self,test_trans):
        # Test every transformation in the transformation list
        for trans in self.transformation:
            match = True
            # Tests every line of trans against test_trans
            # If not equal then unique
            for y in range(len(trans)):
                if trans[y] != test_trans[y]:
                    match = False
            if match:
                return True

        return False
                

    def __str__(self):
        s = "shape_name: "+self.shape_name+"\n"
        s = s + "shape_char: "+self.shape_char
        return s

    def _draw_top(self, stdscr, y, x):
        stdscr.move(y, x)
        stdscr.addch(curses.ACS_ULCORNER)
        for i in range(self.shape_dim):
            stdscr.addch(curses.ACS_HLINE)<commit_msg>Make original shape be transformation[0].<commit_after>import curses
import copy

class Shape(object):

    def __init__(self, shape_def, shape_name, shape_char):
        """ The shape_def is a list of 5 numbers.
        Each number defines one line in the 5x5
        shape table matrix.  The base two representation
        of the number defines if a pixel is on or off.
        """
        self.shape_table = []
        self.transformation = []
        self.shape_dim = len(shape_def)
        self.shape_name = shape_name
        self.shape_char = shape_char
        self.transform_num = 0

        # Create shape_table from the shape_def.
        # shape_table is a list of lists.
        # The 1st dimension specifies the line (row).
        # The 2nd dimension specifies the pixel in the line (column).
        # (0,0) is the upper left corner.
        # A value of 1 indicates the pixel is set.
        # A value of 0 indicates the pixel is not set.
        for line in shape_def:
            line_list = []
            mask = 0x01
            for i in range(self.shape_dim):
                if line & mask:
                    line_list.append(1)
                else:
                    line_list.append(0)
                line = line >> 1
            line_list.reverse()
            self.shape_table.append(line_list)

        # Initialize the transformation list
        self._init_transformation()

    def _init_transformation(self):
        trans = self.shape_table

        # Check the 4 non reflective rotations
        for i in range(4):
            if not self._already_in_transformation(trans):
                self.transformation.append(trans)
            trans = self._rotate_cw(trans)

        # Check the 4 reflective rotations
        trans = self._reflect(self.shape_table)
        for i in range(4):
            if not self._already_in_transformation(trans):
                self.transformation.append(trans)
            trans = self._rotate_cw(trans)

    def _already_in_transformation(self,test_trans):
        # Test every transformation in the transformation list
        for trans in self.transformation:
            match = True
            # Tests every line of trans against test_trans
            # If not equal then unique
            for y in range(len(trans)):
                if trans[y] != test_trans[y]:
                    match = False
            if match:
                return True

        return False
                

    def __str__(self):
        s = "shape_name: "+self.shape_name+"\n"
        s = s + "shape_char: "+self.shape_char
        return s

    def _draw_top(self, stdscr, y, x):
        stdscr.move(y, x)
        stdscr.addch(curses.ACS_ULCORNER)
        for i in range(self.shape_dim):
            stdscr.addch(curses.ACS_HLINE)
{'fraction_non_alphanumeric': 0.07160537482319661, 'fraction_numerical': 0.0072489391796322486, 'mean_word_length': 1.7541382667964946, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2152517', 'n_tokens_mistral': 1604, 'n_tokens_neox': 1512, 'n_words': 483}