<commit_before>from pyawd import utils 
from pyawd import core

class GenericAnimFrame(object):
    def __init__(self, data=None, duration=0):
        self.duration = duration
        self.data = data


class AWDSkeleton(core.AWDBlockBase):
    def __init__(self, name=''):
        super(AWDSkeleton, self).__init__()
        self.name = name
        self.root_joint = None
        

class AWDSkeletonAnimation(core.AWDBlockBase):
    def __init__(self, name=''):
        super(AWDSkeletonAnimation, self).__init__()
        self.name = name
        self.__frames = []

    def add_frame(self, pose, duration):
        dur = int(duration)
        self.__frames.append(GenericAnimFrame(data=pose, duration=dur))


class AWDSkeletonJoint(object):
    def __init__(self, name='', inv_bind_mtx=None):
        super(AWDSkeletonJoint, self).__init__()
        self.name = name
        self.inv_bind_mtx = inv_bind_mtx

        self.__children = []
        self.__parent = None

        if self.inv_bind_mtx is None:
            self.inv_bind_mtx = utils.AWDMatrix4x4()

    def remove_child_joint(self, child):
        self.__children.remove(child)
        
    def add_child_joint(self, child):
        if child.__parent is not None:
            child.__parent.remove_child_joint(child)

        child.__parent = self
        self.__children.append(child)


class AWDSkeletonPose(core.AWDBlockBase):
    def __init__(self, name=''):
        super(AWDSkeletonPose, self).__init__()
        self.name = name
        self.transforms = []

    def add_joint_transform(self, transform=None):
        self.transforms.append(transform)
        

class AWDUVAnimation(core.AWDBlockBase):
    def __init__(self, name=''):
        super(AWDUVAnimation, self).__init__()
        self.name = name
        self.__frames = []

    def add_frame(self, transform, duration):
        dur = int(duration)
        self.__frames.append(GenericAnimFrame(data=transform, duration=dur))
<commit_msg>Improved PyAWD animation block by implementing mapping protocol.<commit_after>from pyawd import utils 
from pyawd import core

class GenericAnimFrame(object):
    def __init__(self, data=None, duration=0):
        self.duration = duration
        self.data = data


class GenericAnim(object):
    def __init__(self, frames):
        super(GenericAnim, self).__init__()
        self.__frames = frames

    def __len__(self):
        return len(self.__frames)

    def __getitem__(self, key):
        idx = int(key)
        return self.__frames[idx]

    def __setitem__(self, key, val):
        idx = int(key)
        if isinstance(val, GenericAnimFrame):
            self.__frames[idx] = val
        else:
            raise ValueError('value must be GenericAnimFrame instance')

    def __contains__(self, item):
        return item in self.__frames


class AWDSkeleton(core.AWDBlockBase):
    def __init__(self, name=''):
        super(AWDSkeleton, self).__init__()
        self.name = name
        self.root_joint = None
        

class AWDSkeletonAnimation(GenericAnim, core.AWDBlockBase):
    def __init__(self, name=''):
        self.name = name
        self.__frames = []
        super(AWDSkeletonAnimation, self).__init__(self.__frames)

    def add_frame(self, pose, duration):
        dur = int(duration)
        self.__frames.append(GenericAnimFrame(data=pose, duration=dur))


class AWDSkeletonJoint(object):
    def __init__(self, name='', inv_bind_mtx=None):
        super(AWDSkeletonJoint, self).__init__()
        self.name = name
        self.inv_bind_mtx = inv_bind_mtx

        self.__children = []
        self.__parent = None

        if self.inv_bind_mtx is None:
            self.inv_bind_mtx = utils.AWDMatrix4x4()

    def remove_child_joint(self, child):
        self.__children.remove(child)
        
    def add_child_joint(self, child):
        if child.__parent is not None:
            child.__parent.remove_child_joint(child)

        child.__parent = self
        self.__children.append(child)


class AWDSkeletonPose(core.AWDBlockBase):
    def __init__(self, name=''):
        super(AWDSkeletonPose, self).__init__()
        self.name = name
        self.transforms = []

    def add_joint_transform(self, transform=None):
        self.transforms.append(transform)
        

class AWDUVAnimation(GenericAnim, core.AWDBlockBase):
    def __init__(self, name=''):
        self.name = name
        self.__frames = []
        super(AWDUVAnimation, self).__init__(self.__frames)

    def add_frame(self, transform, duration):
        dur = int(duration)
        self.__frames.append(GenericAnimFrame(data=transform, duration=dur))




{'fraction_non_alphanumeric': 0.10358221838584376, 'fraction_numerical': 0.001294777729823047, 'mean_word_length': 2.7469684721099434, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5377659', 'n_tokens_mistral': 1432, 'n_tokens_neox': 1381, 'n_words': 286}