<commit_before>from typing import NamedTuple


class Transform(NamedTuple):
    """Type used for 2x3 affine transforms.

    See wikipedia for details:
    http://en.wikipedia.org/wiki/Affine_transformation

    The properties map to the matrix in this way:

    = = ==
    = = ==
    a c tx
    b d ty
    = = ==

    An instance can be created in this way::
        >>> Transform(1,2,3,4,5,6)
        Transform(a=1, b=2, c=3, d=4, tx=5, ty=6)
    Or using the default identity in this way::
        >>> Transform.identity()
        Transform(a=1, b=0, c=0, d=1, tx=0, ty=0)
    Or overriding only some of the values (on a identity matrix):
        >>> Transform(b=3,ty=5)
        Transform(a=1, b=3, c=0, d=1, tx=0, ty=5)


    """

    a: float = 1
    b: float = 0
    c: float = 0
    d: float = 1
    tx: float = 0
    ty: float = 0

    @staticmethod
    def identity() -> "Transform":
        """The identity transform"""
        return Transform(1, 0, 0, 1, 0, 0)<commit_msg>Add some helper methods to create translate, scale and rotate Transforms.<commit_after>import math
from typing import NamedTuple


class Transform(NamedTuple):
    """Type used for 2x3 affine transforms.

    See wikipedia for details:
    http://en.wikipedia.org/wiki/Affine_transformation

    The properties map to the matrix in this way:

    = = ==
    = = ==
    a c tx
    b d ty
    = = ==

    An instance can be created in this way::
        >>> Transform(1,2,3,4,5,6)
        Transform(a=1, b=2, c=3, d=4, tx=5, ty=6)
    Or using the default identity in this way::
        >>> Transform.identity()
        Transform(a=1, b=0, c=0, d=1, tx=0, ty=0)
    Or overriding only some of the values (on a identity matrix):
        >>> Transform(b=3,ty=5)
        Transform(a=1, b=3, c=0, d=1, tx=0, ty=5)


    """

    a: float = 1
    b: float = 0
    c: float = 0
    d: float = 1
    tx: float = 0
    ty: float = 0

    @staticmethod
    def identity() -> "Transform":
        """The identity transform"""
        return Transform(1, 0, 0, 1, 0, 0)

    @staticmethod
    def translation(x, y) -> "Transform":
        return Transform(tx=x, ty=y)

    # split into scale and scale_non-uniform
    @staticmethod
    def scaling(v) -> "Transform":
        return Transform(a=v, d=v)

    @staticmethod
    def rotation(t) -> "Transform":
        c = math.cos(t)
        s = math.sin(t)
        return Transform(a=c, b=s, c=-s, d=c)
{'fraction_non_alphanumeric': 0.13672036348616273, 'fraction_numerical': 0.033044196612969846, 'mean_word_length': 2.331499312242091, 'pattern_counts': {'":': 5, '<': 3, '<?xml version=': 0, '>': 26, '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': '3581904', 'n_tokens_mistral': 894, 'n_tokens_neox': 817, 'n_words': 268}