{
    "file_diffs": [
        {
            "old_file_content": "#\n# The Python Imaging Library.\n# $Id$\n#\n# standard mode descriptors\n#\n# History:\n# 2006-03-20 fl   Added\n#\n# Copyright (c) 2006 by Secret Labs AB.\n# Copyright (c) 2006 by Fredrik Lundh.\n#\n# See the README file for information on usage and redistribution.\n#\n\n# mode descriptor cache\n_modes = {}\n\n\nclass ModeDescriptor(object):\n    \"\"\"Wrapper for mode strings.\"\"\"\n\n    def __init__(self, mode, bands, basemode, basetype):\n        self.mode = mode\n        self.bands = bands\n        self.basemode = basemode\n        self.basetype = basetype\n\n    def __str__(self):\n        return self.mode\n\n\ndef getmode(mode):\n    \"\"\"Gets a mode descriptor for the given mode.\"\"\"\n    if not _modes:\n        # initialize mode cache\n        from PIL import Image\n        # core modes\n        for m, (basemode, basetype, bands) in Image._MODEINFO.items():\n            _modes[m] = ModeDescriptor(m, bands, basemode, basetype)\n        # extra experimental modes\n        _modes[\"LA\"] = ModeDescriptor(\"LA\", (\"L\", \"A\"), \"L\", \"L\")\n        _modes[\"PA\"] = ModeDescriptor(\"PA\", (\"P\", \"A\"), \"RGB\", \"L\")\n        # mapping modes\n        _modes[\"I;16\"] = ModeDescriptor(\"I;16\", \"I\", \"L\", \"L\")\n        _modes[\"I;16L\"] = ModeDescriptor(\"I;16L\", \"I\", \"L\", \"L\")\n        _modes[\"I;16B\"] = ModeDescriptor(\"I;16B\", \"I\", \"L\", \"L\")\n    return _modes[mode]\n\n# End of file\n",
            "new_file_content": "#\n# The Python Imaging Library.\n# $Id$\n#\n# standard mode descriptors\n#\n# History:\n# 2006-03-20 fl   Added\n#\n# Copyright (c) 2006 by Secret Labs AB.\n# Copyright (c) 2006 by Fredrik Lundh.\n#\n# See the README file for information on usage and redistribution.\n#\n\n# mode descriptor cache\n_modes = {}\n\n\nclass ModeDescriptor(object):\n    \"\"\"Wrapper for mode strings.\"\"\"\n\n    def __init__(self, mode, bands, basemode, basetype):\n        self.mode = mode\n        self.bands = bands\n        self.basemode = basemode\n        self.basetype = basetype\n\n    def __str__(self):\n        return self.mode\n\n\ndef getmode(mode):\n    \"\"\"Gets a mode descriptor for the given mode.\"\"\"\n    if not _modes:\n        # initialize mode cache\n        from PIL import Image\n        # core modes\n        for m, (basemode, basetype, bands) in Image._MODEINFO.items():\n            _modes[m] = ModeDescriptor(m, bands, basemode, basetype)\n        # extra experimental modes\n        _modes[\"LA\"] = ModeDescriptor(\"LA\", (\"L\", \"A\"), \"L\", \"L\")\n        _modes[\"La\"] = ModeDescriptor(\"La\", (\"L\", \"a\"), \"L\", \"L\")\n        _modes[\"PA\"] = ModeDescriptor(\"PA\", (\"P\", \"A\"), \"RGB\", \"L\")\n        # mapping modes\n        _modes[\"I;16\"] = ModeDescriptor(\"I;16\", \"I\", \"L\", \"L\")\n        _modes[\"I;16L\"] = ModeDescriptor(\"I;16L\", \"I\", \"L\", \"L\")\n        _modes[\"I;16B\"] = ModeDescriptor(\"I;16B\", \"I\", \"L\", \"L\")\n    return _modes[mode]\n\n# End of file\n",
            "header": {
                "file": {
                    "path": "PIL/ImageMode.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "957ef9c78",
                "new_commit_hash": "3587cec24",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/PIL/ImageMode.py"
            },
            "plus_file": {
                "path": "b/PIL/ImageMode.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 40,
                            "length": 6
                        },
                        "new_range": {
                            "start": 40,
                            "length": 7
                        },
                        "section": "def getmode(mode):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "            _modes[m] = ModeDescriptor(m, bands, basemode, basetype)",
                                "type": "context"
                            },
                            {
                                "content": "        # extra experimental modes",
                                "type": "context"
                            },
                            {
                                "content": "        _modes[\"LA\"] = ModeDescriptor(\"LA\", (\"L\", \"A\"), \"L\", \"L\")",
                                "type": "context"
                            },
                            {
                                "content": "        _modes[\"La\"] = ModeDescriptor(\"La\", (\"L\", \"a\"), \"L\", \"L\")",
                                "type": "added"
                            },
                            {
                                "content": "        _modes[\"PA\"] = ModeDescriptor(\"PA\", (\"P\", \"A\"), \"RGB\", \"L\")",
                                "type": "context"
                            },
                            {
                                "content": "        # mapping modes",
                                "type": "context"
                            },
                            {
                                "content": "        _modes[\"I;16\"] = ModeDescriptor(\"I;16\", \"I\", \"L\", \"L\")",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "PIL/ImageMode.py",
                            "type": "function",
                            "name": "getmode",
                            "content": "def getmode(mode):\n    \"\"\"Gets a mode descriptor for the given mode.\"\"\"\n    if not _modes:\n        # initialize mode cache\n        from PIL import Image\n        # core modes\n        for m, (basemode, basetype, bands) in Image._MODEINFO.items():\n            _modes[m] = ModeDescriptor(m, bands, basemode, basetype)\n        # extra experimental modes\n        _modes[\"LA\"] = ModeDescriptor(\"LA\", (\"L\", \"A\"), \"L\", \"L\")\n        _modes[\"La\"] = ModeDescriptor(\"La\", (\"L\", \"a\"), \"L\", \"L\")\n        _modes[\"PA\"] = ModeDescriptor(\"PA\", (\"P\", \"A\"), \"RGB\", \"L\")\n        # mapping modes\n        _modes[\"I;16\"] = ModeDescriptor(\"I;16\", \"I\", \"L\", \"L\")\n        _modes[\"I;16L\"] = ModeDescriptor(\"I;16L\", \"I\", \"L\", \"L\")\n        _modes[\"I;16B\"] = ModeDescriptor(\"I;16B\", \"I\", \"L\", \"L\")\n    return _modes[mode]",
                            "ast_type_str": "FunctionDef",
                            "start_lineno": 33,
                            "end_lineno": 49,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "from helper import unittest, PillowTestCase, hopper\nfrom PIL import Image, ImageDraw\n\n\nclass TestImagingResampleVulnerability(PillowTestCase):\n    # see https://github.com/python-pillow/Pillow/issues/1710\n    def test_overflow(self):\n        im = hopper('L')\n        xsize = 0x100000008 // 4\n        ysize = 1000  # unimportant\n        try:\n            # any resampling filter will do here\n            im.im.resize((xsize, ysize), Image.LINEAR)\n            self.fail(\"Resize should raise MemoryError on invalid xsize\")\n        except MemoryError:\n            self.assertTrue(True, \"Should raise MemoryError\")\n\n    def test_invalid_size(self):\n        im = hopper()\n\n        im.resize((100, 100))\n        self.assertTrue(True, \"Should not Crash\")\n\n        try:\n            im.resize((-100, 100))\n            self.fail(\"Resize should raise a value error on x negative size\")\n        except ValueError:\n            self.assertTrue(True, \"Should raise ValueError\")\n\n        try:\n            im.resize((100, -100))\n            self.fail(\"Resize should raise a value error on y negative size\")\n        except ValueError:\n            self.assertTrue(True, \"Should raise ValueError\")\n\n\nclass TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))\n\n\nclass CoreResampleConsistencyTest(PillowTestCase):\n    def make_case(self, mode, fill):\n        im = Image.new(mode, (512, 9), fill)\n        return (im.resize((9, 512), Image.LANCZOS), im.load()[0, 0])\n\n    def run_case(self, case):\n        channel, color = case\n        px = channel.load()\n        for x in range(channel.size[0]):\n            for y in range(channel.size[1]):\n                if px[x, y] != color:\n                    message = \"{} != {} for pixel {}\".format(\n                        px[x, y], color, (x, y))\n                    self.assertEqual(px[x, y], color, message)\n\n    def test_8u(self):\n        im, color = self.make_case('RGB', (0, 64, 255))\n        r, g, b = im.split()\n        self.run_case((r, color[0]))\n        self.run_case((g, color[1]))\n        self.run_case((b, color[2]))\n        self.run_case(self.make_case('L', 12))\n\n    def test_32i(self):\n        self.run_case(self.make_case('I', 12))\n        self.run_case(self.make_case('I', 0x7fffffff))\n        self.run_case(self.make_case('I', -12))\n        self.run_case(self.make_case('I', -1 << 31))\n\n    def test_32f(self):\n        self.run_case(self.make_case('F', 1))\n        self.run_case(self.make_case('F', 3.40282306074e+38))\n        self.run_case(self.make_case('F', 1.175494e-38))\n        self.run_case(self.make_case('F', 1.192093e-07))\n\n\nclass CoreResampleAlphaCorrectTest(PillowTestCase):\n    def make_levels_case(self, mode):\n        i = Image.new(mode, (256, 16))\n        px = i.load()\n        for y in range(i.size[1]):\n            for x in range(i.size[0]):\n                pix = [x] * len(mode)\n                pix[-1] = 255 - y * 16\n                px[x, y] = tuple(pix)\n        return i\n\n    def run_levels_case(self, i):\n        px = i.load()\n        for y in range(i.size[1]):\n            used_colors = set(px[x, y][0] for x in range(i.size[0]))\n            self.assertEqual(256, len(used_colors),\n                'All colors should present in resized image. '\n                'Only {0} on {1} line.'.format(len(used_colors), y))\n\n    @unittest.skip(\"current implementation isn't precise enough\")\n    def test_levels_rgba(self):\n        case = self.make_levels_case('RGBA')\n        self.run_levels_case(case.resize((512, 32), Image.BILINEAR))\n        self.run_levels_case(case.resize((512, 32), Image.BICUBIC))\n        self.run_levels_case(case.resize((512, 32), Image.LANCZOS))\n\n    @unittest.skip(\"current implementation isn't precise enough\")\n    def test_levels_la(self):\n        case = self.make_levels_case('LA')\n        self.run_levels_case(case.resize((512, 32), Image.BILINEAR))\n        self.run_levels_case(case.resize((512, 32), Image.BICUBIC))\n        self.run_levels_case(case.resize((512, 32), Image.LANCZOS))\n\n    def make_dity_case(self, mode, clean_pixel, dirty_pixel):\n        i = Image.new(mode, (64, 64), dirty_pixel)\n        px = i.load()\n        xdiv4 = i.size[0] // 4\n        ydiv4 = i.size[1] // 4\n        for y in range(ydiv4 * 2):\n            for x in range(xdiv4 * 2):\n                px[x + xdiv4, y + ydiv4] = clean_pixel\n        return i\n\n    def run_dity_case(self, i, clean_pixel):\n        px = i.load()\n        for y in range(i.size[1]):\n            for x in range(i.size[0]):\n                if px[x, y][-1] != 0 and px[x, y][:-1] != clean_pixel:\n                    message = 'pixel at ({0}, {1}) is differ:\\n{2}\\n{3}'\\\n                        .format(x, y, px[x, y], clean_pixel)\n                    self.assertEqual(px[x, y][:3], clean_pixel, message)\n\n    def test_dirty_pixels_rgba(self):\n        case = self.make_dity_case('RGBA', (255, 255, 0, 128), (0, 0, 255, 0))\n        self.run_dity_case(case.resize((20, 20), Image.BILINEAR), (255, 255, 0))\n        self.run_dity_case(case.resize((20, 20), Image.BICUBIC), (255, 255, 0))\n        self.run_dity_case(case.resize((20, 20), Image.LANCZOS), (255, 255, 0))\n\n    def test_dirty_pixels_la(self):\n        case = self.make_dity_case('LA', (255, 128), (0, 0))\n        self.run_dity_case(case.resize((20, 20), Image.BILINEAR), (255,))\n        self.run_dity_case(case.resize((20, 20), Image.BICUBIC), (255,))\n        self.run_dity_case(case.resize((20, 20), Image.LANCZOS), (255,))\n\n\nif __name__ == '__main__':\n    unittest.main()\n",
            "new_file_content": "from helper import unittest, PillowTestCase, hopper\nfrom PIL import Image, ImageDraw, ImageMode\n\n\nclass TestImagingResampleVulnerability(PillowTestCase):\n    # see https://github.com/python-pillow/Pillow/issues/1710\n    def test_overflow(self):\n        im = hopper('L')\n        xsize = 0x100000008 // 4\n        ysize = 1000  # unimportant\n        try:\n            # any resampling filter will do here\n            im.im.resize((xsize, ysize), Image.LINEAR)\n            self.fail(\"Resize should raise MemoryError on invalid xsize\")\n        except MemoryError:\n            self.assertTrue(True, \"Should raise MemoryError\")\n\n    def test_invalid_size(self):\n        im = hopper()\n\n        im.resize((100, 100))\n        self.assertTrue(True, \"Should not Crash\")\n\n        try:\n            im.resize((-100, 100))\n            self.fail(\"Resize should raise a value error on x negative size\")\n        except ValueError:\n            self.assertTrue(True, \"Should raise ValueError\")\n\n        try:\n            im.resize((100, -100))\n            self.fail(\"Resize should raise a value error on y negative size\")\n        except ValueError:\n            self.assertTrue(True, \"Should raise ValueError\")\n\n\nclass TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        case = Image.new('L', size, 255 - color)\n        rectangle = ImageDraw.Draw(case).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), color)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), color)\n\n        return Image.merge(mode, [case] *  len(mode))\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'La', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'La', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'La', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'La', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'La', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'La', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))\n\n\nclass CoreResampleConsistencyTest(PillowTestCase):\n    def make_case(self, mode, fill):\n        im = Image.new(mode, (512, 9), fill)\n        return (im.resize((9, 512), Image.LANCZOS), im.load()[0, 0])\n\n    def run_case(self, case):\n        channel, color = case\n        px = channel.load()\n        for x in range(channel.size[0]):\n            for y in range(channel.size[1]):\n                if px[x, y] != color:\n                    message = \"{} != {} for pixel {}\".format(\n                        px[x, y], color, (x, y))\n                    self.assertEqual(px[x, y], color, message)\n\n    def test_8u(self):\n        im, color = self.make_case('RGB', (0, 64, 255))\n        r, g, b = im.split()\n        self.run_case((r, color[0]))\n        self.run_case((g, color[1]))\n        self.run_case((b, color[2]))\n        self.run_case(self.make_case('L', 12))\n\n    def test_32i(self):\n        self.run_case(self.make_case('I', 12))\n        self.run_case(self.make_case('I', 0x7fffffff))\n        self.run_case(self.make_case('I', -12))\n        self.run_case(self.make_case('I', -1 << 31))\n\n    def test_32f(self):\n        self.run_case(self.make_case('F', 1))\n        self.run_case(self.make_case('F', 3.40282306074e+38))\n        self.run_case(self.make_case('F', 1.175494e-38))\n        self.run_case(self.make_case('F', 1.192093e-07))\n\n\nclass CoreResampleAlphaCorrectTest(PillowTestCase):\n    def make_levels_case(self, mode):\n        i = Image.new(mode, (256, 16))\n        px = i.load()\n        for y in range(i.size[1]):\n            for x in range(i.size[0]):\n                pix = [x] * len(mode)\n                pix[-1] = 255 - y * 16\n                px[x, y] = tuple(pix)\n        return i\n\n    def run_levels_case(self, i):\n        px = i.load()\n        for y in range(i.size[1]):\n            used_colors = set(px[x, y][0] for x in range(i.size[0]))\n            self.assertEqual(256, len(used_colors),\n                'All colors should present in resized image. '\n                'Only {0} on {1} line.'.format(len(used_colors), y))\n\n    @unittest.skip(\"current implementation isn't precise enough\")\n    def test_levels_rgba(self):\n        case = self.make_levels_case('RGBA')\n        self.run_levels_case(case.resize((512, 32), Image.BILINEAR))\n        self.run_levels_case(case.resize((512, 32), Image.BICUBIC))\n        self.run_levels_case(case.resize((512, 32), Image.LANCZOS))\n\n    @unittest.skip(\"current implementation isn't precise enough\")\n    def test_levels_la(self):\n        case = self.make_levels_case('LA')\n        self.run_levels_case(case.resize((512, 32), Image.BILINEAR))\n        self.run_levels_case(case.resize((512, 32), Image.BICUBIC))\n        self.run_levels_case(case.resize((512, 32), Image.LANCZOS))\n\n    def make_dity_case(self, mode, clean_pixel, dirty_pixel):\n        i = Image.new(mode, (64, 64), dirty_pixel)\n        px = i.load()\n        xdiv4 = i.size[0] // 4\n        ydiv4 = i.size[1] // 4\n        for y in range(ydiv4 * 2):\n            for x in range(xdiv4 * 2):\n                px[x + xdiv4, y + ydiv4] = clean_pixel\n        return i\n\n    def run_dity_case(self, i, clean_pixel):\n        px = i.load()\n        for y in range(i.size[1]):\n            for x in range(i.size[0]):\n                if px[x, y][-1] != 0 and px[x, y][:-1] != clean_pixel:\n                    message = 'pixel at ({0}, {1}) is differ:\\n{2}\\n{3}'\\\n                        .format(x, y, px[x, y], clean_pixel)\n                    self.assertEqual(px[x, y][:3], clean_pixel, message)\n\n    def test_dirty_pixels_rgba(self):\n        case = self.make_dity_case('RGBA', (255, 255, 0, 128), (0, 0, 255, 0))\n        self.run_dity_case(case.resize((20, 20), Image.BILINEAR), (255, 255, 0))\n        self.run_dity_case(case.resize((20, 20), Image.BICUBIC), (255, 255, 0))\n        self.run_dity_case(case.resize((20, 20), Image.LANCZOS), (255, 255, 0))\n\n    def test_dirty_pixels_la(self):\n        case = self.make_dity_case('LA', (255, 128), (0, 0))\n        self.run_dity_case(case.resize((20, 20), Image.BILINEAR), (255,))\n        self.run_dity_case(case.resize((20, 20), Image.BICUBIC), (255,))\n        self.run_dity_case(case.resize((20, 20), Image.LANCZOS), (255,))\n\n\nif __name__ == '__main__':\n    unittest.main()\n",
            "header": {
                "file": {
                    "path": "Tests/test_image_resample.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "353e0d603",
                "new_commit_hash": "9ee9ac48f",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/Tests/test_image_resample.py"
            },
            "plus_file": {
                "path": "b/Tests/test_image_resample.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 1,
                            "length": 5
                        },
                        "new_range": {
                            "start": 1,
                            "length": 5
                        },
                        "section": ""
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "from helper import unittest, PillowTestCase, hopper",
                                "type": "context"
                            },
                            {
                                "content": "from PIL import Image, ImageDraw",
                                "type": "deleted"
                            },
                            {
                                "content": "from PIL import Image, ImageDraw, ImageMode",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "class TestImagingResampleVulnerability(PillowTestCase):",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [],
                    "added_entities": [
                        {
                            "file_name": "Tests/test_image_resample.py",
                            "type": "statement",
                            "name": "",
                            "content": "from PIL import Image, ImageDraw, ImageMode",
                            "ast_type_str": "ImportFrom",
                            "start_lineno": 2,
                            "end_lineno": 2,
                            "parent": null
                        }
                    ],
                    "deleted_entities": [
                        {
                            "file_name": "Tests/test_image_resample.py",
                            "type": "statement",
                            "name": "",
                            "content": "from PIL import Image, ImageDraw",
                            "ast_type_str": "ImportFrom",
                            "start_lineno": 2,
                            "end_lineno": 2,
                            "parent": null
                        }
                    ]
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 43,
                            "length": 14
                        },
                        "new_range": {
                            "start": 43,
                            "length": 12
                        },
                        "section": "class TestImagingCoreResampleAccuracy(PillowTestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        1f 1f e0 e0",
                                "type": "context"
                            },
                            {
                                "content": "        1f 1f e0 e0",
                                "type": "context"
                            },
                            {
                                "content": "        \"\"\"",
                                "type": "context"
                            },
                            {
                                "content": "        dark = (255 - color, 255 - color, 255 - color, 255 - color)",
                                "type": "deleted"
                            },
                            {
                                "content": "        bright = (color, color, color, color)",
                                "type": "deleted"
                            },
                            {
                                "content": "        case = Image.new('L', size, 255 - color)",
                                "type": "added"
                            },
                            {
                                "content": "        rectangle = ImageDraw.Draw(case).rectangle",
                                "type": "added"
                            },
                            {
                                "content": "        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), color)",
                                "type": "added"
                            },
                            {
                                "content": "        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), color)",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "        i = Image.new('RGBX', size, dark)",
                                "type": "deleted"
                            },
                            {
                                "content": "        rectangle = ImageDraw.Draw(i).rectangle",
                                "type": "deleted"
                            },
                            {
                                "content": "        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)",
                                "type": "deleted"
                            },
                            {
                                "content": "        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)",
                                "type": "deleted"
                            },
                            {
                                "content": "        return i.convert(mode)",
                                "type": "deleted"
                            },
                            {
                                "content": "        return Image.merge(mode, [case] *  len(mode))",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def make_sample(self, data, size):",
                                "type": "context"
                            },
                            {
                                "content": "        \"\"\"Restores a sample image from given data string which contains",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Tests/test_image_resample.py",
                            "type": "class",
                            "name": "TestImagingCoreResampleAccuracy",
                            "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 37,
                            "end_lineno": 155,
                            "parent": null
                        },
                        {
                            "file_name": "Tests/test_image_resample.py",
                            "type": "method",
                            "name": "TestImagingCoreResampleAccuracy.make_case",
                            "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 38,
                            "end_lineno": 53,
                            "parent": {
                                "file_name": "Tests/test_image_resample.py",
                                "type": "class",
                                "name": "TestImagingCoreResampleAccuracy",
                                "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 37,
                                "end_lineno": 155,
                                "parent": null
                            }
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 92,
                            "length": 7
                        },
                        "new_range": {
                            "start": 90,
                            "length": 7
                        },
                        "section": "class TestImagingCoreResampleAccuracy(PillowTestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        )",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def test_reduce_bilinear(self):",
                                "type": "context"
                            },
                            {
                                "content": "        for mode in ['RGBX', 'RGB', 'L']:",
                                "type": "deleted"
                            },
                            {
                                "content": "        for mode in ['RGBX', 'RGB', 'La', 'L']:",
                                "type": "added"
                            },
                            {
                                "content": "            case = self.make_case(mode, (8, 8), 0xe1)",
                                "type": "context"
                            },
                            {
                                "content": "            case = case.resize((4, 4), Image.BILINEAR)",
                                "type": "context"
                            },
                            {
                                "content": "            data = ('e1 c9'",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Tests/test_image_resample.py",
                            "type": "method",
                            "name": "TestImagingCoreResampleAccuracy.test_reduce_bilinear",
                            "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 94,
                            "end_lineno": 101,
                            "parent": {
                                "file_name": "Tests/test_image_resample.py",
                                "type": "class",
                                "name": "TestImagingCoreResampleAccuracy",
                                "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 37,
                                "end_lineno": 155,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "Tests/test_image_resample.py",
                            "type": "class",
                            "name": "TestImagingCoreResampleAccuracy",
                            "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 37,
                            "end_lineno": 155,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 101,
                            "length": 7
                        },
                        "new_range": {
                            "start": 99,
                            "length": 7
                        },
                        "section": "class TestImagingCoreResampleAccuracy(PillowTestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "                self.check_case(channel, self.make_sample(data, (4, 4)))",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def test_reduce_bicubic(self):",
                                "type": "context"
                            },
                            {
                                "content": "        for mode in ['RGBX', 'RGB', 'L']:",
                                "type": "deleted"
                            },
                            {
                                "content": "        for mode in ['RGBX', 'RGB', 'La', 'L']:",
                                "type": "added"
                            },
                            {
                                "content": "            case = self.make_case(mode, (12, 12), 0xe1)",
                                "type": "context"
                            },
                            {
                                "content": "            case = case.resize((6, 6), Image.BICUBIC)",
                                "type": "context"
                            },
                            {
                                "content": "            data = ('e1 e3 d4'",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Tests/test_image_resample.py",
                            "type": "class",
                            "name": "TestImagingCoreResampleAccuracy",
                            "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 37,
                            "end_lineno": 155,
                            "parent": null
                        },
                        {
                            "file_name": "Tests/test_image_resample.py",
                            "type": "method",
                            "name": "TestImagingCoreResampleAccuracy.test_reduce_bicubic",
                            "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 103,
                            "end_lineno": 111,
                            "parent": {
                                "file_name": "Tests/test_image_resample.py",
                                "type": "class",
                                "name": "TestImagingCoreResampleAccuracy",
                                "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 37,
                                "end_lineno": 155,
                                "parent": null
                            }
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 111,
                            "length": 7
                        },
                        "new_range": {
                            "start": 109,
                            "length": 7
                        },
                        "section": "class TestImagingCoreResampleAccuracy(PillowTestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "                self.check_case(channel, self.make_sample(data, (6, 6)))",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def test_reduce_lanczos(self):",
                                "type": "context"
                            },
                            {
                                "content": "        for mode in ['RGBX', 'RGB', 'L']:",
                                "type": "deleted"
                            },
                            {
                                "content": "        for mode in ['RGBX', 'RGB', 'La', 'L']:",
                                "type": "added"
                            },
                            {
                                "content": "            case = self.make_case(mode, (16, 16), 0xe1)",
                                "type": "context"
                            },
                            {
                                "content": "            case = case.resize((8, 8), Image.LANCZOS)",
                                "type": "context"
                            },
                            {
                                "content": "            data = ('e1 e0 e4 d7'",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Tests/test_image_resample.py",
                            "type": "class",
                            "name": "TestImagingCoreResampleAccuracy",
                            "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 37,
                            "end_lineno": 155,
                            "parent": null
                        },
                        {
                            "file_name": "Tests/test_image_resample.py",
                            "type": "method",
                            "name": "TestImagingCoreResampleAccuracy.test_reduce_lanczos",
                            "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 113,
                            "end_lineno": 122,
                            "parent": {
                                "file_name": "Tests/test_image_resample.py",
                                "type": "class",
                                "name": "TestImagingCoreResampleAccuracy",
                                "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 37,
                                "end_lineno": 155,
                                "parent": null
                            }
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 122,
                            "length": 7
                        },
                        "new_range": {
                            "start": 120,
                            "length": 7
                        },
                        "section": "class TestImagingCoreResampleAccuracy(PillowTestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "                self.check_case(channel, self.make_sample(data, (8, 8)))",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def test_enlarge_bilinear(self):",
                                "type": "context"
                            },
                            {
                                "content": "        for mode in ['RGBX', 'RGB', 'L']:",
                                "type": "deleted"
                            },
                            {
                                "content": "        for mode in ['RGBX', 'RGB', 'La', 'L']:",
                                "type": "added"
                            },
                            {
                                "content": "            case = self.make_case(mode, (2, 2), 0xe1)",
                                "type": "context"
                            },
                            {
                                "content": "            case = case.resize((4, 4), Image.BILINEAR)",
                                "type": "context"
                            },
                            {
                                "content": "            data = ('e1 b0'",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Tests/test_image_resample.py",
                            "type": "class",
                            "name": "TestImagingCoreResampleAccuracy",
                            "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 37,
                            "end_lineno": 155,
                            "parent": null
                        },
                        {
                            "file_name": "Tests/test_image_resample.py",
                            "type": "method",
                            "name": "TestImagingCoreResampleAccuracy.test_enlarge_bilinear",
                            "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 124,
                            "end_lineno": 131,
                            "parent": {
                                "file_name": "Tests/test_image_resample.py",
                                "type": "class",
                                "name": "TestImagingCoreResampleAccuracy",
                                "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 37,
                                "end_lineno": 155,
                                "parent": null
                            }
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 131,
                            "length": 7
                        },
                        "new_range": {
                            "start": 129,
                            "length": 7
                        },
                        "section": "class TestImagingCoreResampleAccuracy(PillowTestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "                self.check_case(channel, self.make_sample(data, (4, 4)))",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def test_enlarge_bicubic(self):",
                                "type": "context"
                            },
                            {
                                "content": "        for mode in ['RGBX', 'RGB', 'L']:",
                                "type": "deleted"
                            },
                            {
                                "content": "        for mode in ['RGBX', 'RGB', 'La', 'L']:",
                                "type": "added"
                            },
                            {
                                "content": "            case = self.make_case(mode, (4, 4), 0xe1)",
                                "type": "context"
                            },
                            {
                                "content": "            case = case.resize((8, 8), Image.BICUBIC)",
                                "type": "context"
                            },
                            {
                                "content": "            data = ('e1 e5 ee b9'",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Tests/test_image_resample.py",
                            "type": "class",
                            "name": "TestImagingCoreResampleAccuracy",
                            "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 37,
                            "end_lineno": 155,
                            "parent": null
                        },
                        {
                            "file_name": "Tests/test_image_resample.py",
                            "type": "method",
                            "name": "TestImagingCoreResampleAccuracy.test_enlarge_bicubic",
                            "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 133,
                            "end_lineno": 142,
                            "parent": {
                                "file_name": "Tests/test_image_resample.py",
                                "type": "class",
                                "name": "TestImagingCoreResampleAccuracy",
                                "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 37,
                                "end_lineno": 155,
                                "parent": null
                            }
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 142,
                            "length": 7
                        },
                        "new_range": {
                            "start": 140,
                            "length": 7
                        },
                        "section": "class TestImagingCoreResampleAccuracy(PillowTestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "                self.check_case(channel, self.make_sample(data, (8, 8)))",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def test_enlarge_lanczos(self):",
                                "type": "context"
                            },
                            {
                                "content": "        for mode in ['RGBX', 'RGB', 'L']:",
                                "type": "deleted"
                            },
                            {
                                "content": "        for mode in ['RGBX', 'RGB', 'La', 'L']:",
                                "type": "added"
                            },
                            {
                                "content": "            case = self.make_case(mode, (6, 6), 0xe1)",
                                "type": "context"
                            },
                            {
                                "content": "            case = case.resize((12, 12), Image.LANCZOS)",
                                "type": "context"
                            },
                            {
                                "content": "            data = ('e1 e0 db ed f5 b8'",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Tests/test_image_resample.py",
                            "type": "method",
                            "name": "TestImagingCoreResampleAccuracy.test_enlarge_lanczos",
                            "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 144,
                            "end_lineno": 155,
                            "parent": {
                                "file_name": "Tests/test_image_resample.py",
                                "type": "class",
                                "name": "TestImagingCoreResampleAccuracy",
                                "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 37,
                                "end_lineno": 155,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "Tests/test_image_resample.py",
                            "type": "class",
                            "name": "TestImagingCoreResampleAccuracy",
                            "content": "class TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        dark = (255 - color, 255 - color, 255 - color, 255 - color)\n        bright = (color, color, color, color)\n\n        i = Image.new('RGBX', size, dark)\n        rectangle = ImageDraw.Draw(i).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), bright)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), bright)\n        return i.convert(mode)\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 37,
                            "end_lineno": 155,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        }
    ],
    "old_commit_hash": "f09067e45eeecdd85e8d379ddb7f2ea581e08708^",
    "new_commit_hash": "f09067e45eeecdd85e8d379ddb7f2ea581e08708",
    "commit_message": "add La mode (2 bands) to the test",
    "commit_date": "2016-05-28T10:47:14+03:00",
    "metadata": {}
}
{
    "repo_name": "pillow",
    "new_commit_hash": "f09067e45eeecdd85e8d379ddb7f2ea581e08708",
    "test_file_codes": [
        "from helper import unittest, PillowTestCase, hopper\nfrom PIL import Image, ImageDraw, ImageMode\n\n\nclass TestImagingResampleVulnerability(PillowTestCase):\n    # see https://github.com/python-pillow/Pillow/issues/1710\n    def test_overflow(self):\n        im = hopper('L')\n        xsize = 0x100000008 // 4\n        ysize = 1000  # unimportant\n        try:\n            # any resampling filter will do here\n            im.im.resize((xsize, ysize), Image.LINEAR)\n            self.fail(\"Resize should raise MemoryError on invalid xsize\")\n        except MemoryError:\n            self.assertTrue(True, \"Should raise MemoryError\")\n\n    def test_invalid_size(self):\n        im = hopper()\n\n        im.resize((100, 100))\n        self.assertTrue(True, \"Should not Crash\")\n\n        try:\n            im.resize((-100, 100))\n            self.fail(\"Resize should raise a value error on x negative size\")\n        except ValueError:\n            self.assertTrue(True, \"Should raise ValueError\")\n\n        try:\n            im.resize((100, -100))\n            self.fail(\"Resize should raise a value error on y negative size\")\n        except ValueError:\n            self.assertTrue(True, \"Should raise ValueError\")\n\n\nclass TestImagingCoreResampleAccuracy(PillowTestCase):\n    def make_case(self, mode, size, color):\n        \"\"\"Makes a sample image with two dark and two bright squares.\n        For example:\n        e0 e0 1f 1f\n        e0 e0 1f 1f\n        1f 1f e0 e0\n        1f 1f e0 e0\n        \"\"\"\n        case = Image.new('L', size, 255 - color)\n        rectangle = ImageDraw.Draw(case).rectangle\n        rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), color)\n        rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), color)\n\n        return Image.merge(mode, [case] *  len(mode))\n\n    def make_sample(self, data, size):\n        \"\"\"Restores a sample image from given data string which contains\n        hex-encoded pixels from the top left fourth of a sample.\n        \"\"\"\n        data = data.replace(' ', '')\n        sample = Image.new('L', size)\n        s_px = sample.load()\n        w, h = size[0] // 2, size[1] // 2\n        for y in range(h):\n            for x in range(w):\n                val = int(data[(y * w + x) * 2:(y * w + x + 1) * 2], 16)\n                s_px[x, y] = val\n                s_px[size[0] - x - 1, size[1] - y - 1] = val\n                s_px[x, size[1] - y - 1] = 255 - val\n                s_px[size[0] - x - 1, y] = 255 - val\n        return sample\n\n    def check_case(self, case, sample):\n        s_px = sample.load()\n        c_px = case.load()\n        for y in range(case.size[1]):\n            for x in range(case.size[0]):\n                if c_px[x, y] != s_px[x, y]:\n                    message = '\\nHave: \\n{}\\n\\nExpected: \\n{}'.format(\n                        self.serialize_image(case),\n                        self.serialize_image(sample),\n                    )\n                    self.assertEqual(s_px[x, y], c_px[x, y], message)\n\n    def serialize_image(self, image):\n        s_px = image.load()\n        return '\\n'.join(\n            ' '.join(\n                '{:02x}'.format(s_px[x, y])\n                for x in range(image.size[0])\n            )\n            for y in range(image.size[1])\n        )\n\n    def test_reduce_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'La', 'L']:\n            case = self.make_case(mode, (8, 8), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 c9'\n                    'c9 b7')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_reduce_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'La', 'L']:\n            case = self.make_case(mode, (12, 12), 0xe1)\n            case = case.resize((6, 6), Image.BICUBIC)\n            data = ('e1 e3 d4'\n                    'e3 e5 d6'\n                    'd4 d6 c9')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (6, 6)))\n\n    def test_reduce_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'La', 'L']:\n            case = self.make_case(mode, (16, 16), 0xe1)\n            case = case.resize((8, 8), Image.LANCZOS)\n            data = ('e1 e0 e4 d7'\n                    'e0 df e3 d6'\n                    'e4 e3 e7 da'\n                    'd7 d6 d9 ce')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_bilinear(self):\n        for mode in ['RGBX', 'RGB', 'La', 'L']:\n            case = self.make_case(mode, (2, 2), 0xe1)\n            case = case.resize((4, 4), Image.BILINEAR)\n            data = ('e1 b0'\n                    'b0 98')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (4, 4)))\n\n    def test_enlarge_bicubic(self):\n        for mode in ['RGBX', 'RGB', 'La', 'L']:\n            case = self.make_case(mode, (4, 4), 0xe1)\n            case = case.resize((8, 8), Image.BICUBIC)\n            data = ('e1 e5 ee b9'\n                    'e5 e9 f3 bc'\n                    'ee f3 fd c1'\n                    'b9 bc c1 a2')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (8, 8)))\n\n    def test_enlarge_lanczos(self):\n        for mode in ['RGBX', 'RGB', 'La', 'L']:\n            case = self.make_case(mode, (6, 6), 0xe1)\n            case = case.resize((12, 12), Image.LANCZOS)\n            data = ('e1 e0 db ed f5 b8'\n                    'e0 df da ec f3 b7'\n                    'db db d6 e7 ee b5'\n                    'ed ec e6 fb ff bf'\n                    'f5 f4 ee ff ff c4'\n                    'b8 b7 b4 bf c4 a0')\n            for channel in case.split():\n                self.check_case(channel, self.make_sample(data, (12, 12)))\n\n\nclass CoreResampleConsistencyTest(PillowTestCase):\n    def make_case(self, mode, fill):\n        im = Image.new(mode, (512, 9), fill)\n        return (im.resize((9, 512), Image.LANCZOS), im.load()[0, 0])\n\n    def run_case(self, case):\n        channel, color = case\n        px = channel.load()\n        for x in range(channel.size[0]):\n            for y in range(channel.size[1]):\n                if px[x, y] != color:\n                    message = \"{} != {} for pixel {}\".format(\n                        px[x, y], color, (x, y))\n                    self.assertEqual(px[x, y], color, message)\n\n    def test_8u(self):\n        im, color = self.make_case('RGB', (0, 64, 255))\n        r, g, b = im.split()\n        self.run_case((r, color[0]))\n        self.run_case((g, color[1]))\n        self.run_case((b, color[2]))\n        self.run_case(self.make_case('L', 12))\n\n    def test_32i(self):\n        self.run_case(self.make_case('I', 12))\n        self.run_case(self.make_case('I', 0x7fffffff))\n        self.run_case(self.make_case('I', -12))\n        self.run_case(self.make_case('I', -1 << 31))\n\n    def test_32f(self):\n        self.run_case(self.make_case('F', 1))\n        self.run_case(self.make_case('F', 3.40282306074e+38))\n        self.run_case(self.make_case('F', 1.175494e-38))\n        self.run_case(self.make_case('F', 1.192093e-07))\n\n\nclass CoreResampleAlphaCorrectTest(PillowTestCase):\n    def make_levels_case(self, mode):\n        i = Image.new(mode, (256, 16))\n        px = i.load()\n        for y in range(i.size[1]):\n            for x in range(i.size[0]):\n                pix = [x] * len(mode)\n                pix[-1] = 255 - y * 16\n                px[x, y] = tuple(pix)\n        return i\n\n    def run_levels_case(self, i):\n        px = i.load()\n        for y in range(i.size[1]):\n            used_colors = set(px[x, y][0] for x in range(i.size[0]))\n            self.assertEqual(256, len(used_colors),\n                'All colors should present in resized image. '\n                'Only {0} on {1} line.'.format(len(used_colors), y))\n\n    @unittest.skip(\"current implementation isn't precise enough\")\n    def test_levels_rgba(self):\n        case = self.make_levels_case('RGBA')\n        self.run_levels_case(case.resize((512, 32), Image.BILINEAR))\n        self.run_levels_case(case.resize((512, 32), Image.BICUBIC))\n        self.run_levels_case(case.resize((512, 32), Image.LANCZOS))\n\n    @unittest.skip(\"current implementation isn't precise enough\")\n    def test_levels_la(self):\n        case = self.make_levels_case('LA')\n        self.run_levels_case(case.resize((512, 32), Image.BILINEAR))\n        self.run_levels_case(case.resize((512, 32), Image.BICUBIC))\n        self.run_levels_case(case.resize((512, 32), Image.LANCZOS))\n\n    def make_dity_case(self, mode, clean_pixel, dirty_pixel):\n        i = Image.new(mode, (64, 64), dirty_pixel)\n        px = i.load()\n        xdiv4 = i.size[0] // 4\n        ydiv4 = i.size[1] // 4\n        for y in range(ydiv4 * 2):\n            for x in range(xdiv4 * 2):\n                px[x + xdiv4, y + ydiv4] = clean_pixel\n        return i\n\n    def run_dity_case(self, i, clean_pixel):\n        px = i.load()\n        for y in range(i.size[1]):\n            for x in range(i.size[0]):\n                if px[x, y][-1] != 0 and px[x, y][:-1] != clean_pixel:\n                    message = 'pixel at ({0}, {1}) is differ:\\n{2}\\n{3}'\\\n                        .format(x, y, px[x, y], clean_pixel)\n                    self.assertEqual(px[x, y][:3], clean_pixel, message)\n\n    def test_dirty_pixels_rgba(self):\n        case = self.make_dity_case('RGBA', (255, 255, 0, 128), (0, 0, 255, 0))\n        self.run_dity_case(case.resize((20, 20), Image.BILINEAR), (255, 255, 0))\n        self.run_dity_case(case.resize((20, 20), Image.BICUBIC), (255, 255, 0))\n        self.run_dity_case(case.resize((20, 20), Image.LANCZOS), (255, 255, 0))\n\n    def test_dirty_pixels_la(self):\n        case = self.make_dity_case('LA', (255, 128), (0, 0))\n        self.run_dity_case(case.resize((20, 20), Image.BILINEAR), (255,))\n        self.run_dity_case(case.resize((20, 20), Image.BICUBIC), (255,))\n        self.run_dity_case(case.resize((20, 20), Image.LANCZOS), (255,))\n\n\nif __name__ == '__main__':\n    unittest.main()\n",
        "#!/usr/bin/env python\nimport unittest\nimport sys\nimport time\nimport traceback\nimport platform\nimport os\n\n\nclass PytestLikeResult(unittest.TestResult):\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self.start_time = None\n        # Store (test, outcome, info) for each test:\n        #   outcome ∈ { \"passed\", \"failed\", \"error\", \"skipped\" }\n        #   info can hold the exception or skip reason, etc.\n        self.results = []\n\n    def startTestRun(self):\n        \"\"\"Called once before all tests.\"\"\"\n        self.start_time = time.time()\n        # Print a header similar to pytest\n        print(\"=\" * 29 + \" test session starts \" + \"=\" * 29)\n        # You can customize the platform/versions/paths as you like:\n        print(\n            f\"platform {platform.system().lower()} -- Python {platform.python_version()}\"\n        )\n        print(f\"rootdir: {os.path.abspath(os.curdir)}\")\n\n    def stopTestRun(self):\n        \"\"\"Called once after all tests are done.\"\"\"\n        elapsed = time.time() - self.start_time\n        print()  # blank line after final dot\n\n        # Summarize\n        ntests = len(self.results)\n        print(f\"collected {ntests} items\")\n\n        # Show details of failures/errors\n        failures = [r for r in self.results if r[1] == \"failed\"]\n        errors = [r for r in self.results if r[1] == \"error\"]\n\n        if failures:\n            print(\"\\n\" + \"=\" * 35 + \" FAILURES \" + \"=\" * 35)\n            for test, outcome, err_info in failures:\n                test = test.split(\"::\")\n                if len(test) == 3:\n                    test = f\"{test[1]}.{test[2]}\"\n                else:\n                    test = f\"{test[1]}\"\n                print(f\"__________ {test} __________\")\n                self._print_traceback(err_info)\n        if errors:\n            print(\"\\n\" + \"=\" * 35 + \" ERRORS \" + \"=\" * 37)\n            for test, outcome, err_info in errors:\n                test = test.split(\"::\")\n                if len(test) == 3:\n                    test = f\"{test[1]}.{test[2]}\"\n                else:\n                    test = f\"{test[1]}\"\n                print(f\"__________ {test} __________\")\n                self._print_traceback(err_info)\n\n        # Optional short summary lines for passes/fails/skips\n        print(\"\\n==================== short test summary info ====================\")\n        for test, outcome, info in self.results:\n            if outcome in (\"passed\", \"failed\", \"error\", \"skipped\"):\n                print(f\"{outcome.upper()} {test}\")\n\n        # Final one-line summary: “1 failed, 1 errors, 10 passed in 2.04s”\n        passed_count = sum(1 for r in self.results if r[1] == \"passed\")\n        failed_count = len(failures)\n        error_count = len(errors)\n        skipped_count = sum(1 for r in self.results if r[1] == \"skipped\")\n\n        summary_bits = []\n        if failed_count:\n            summary_bits.append(f\"{failed_count} failed\")\n        if error_count:\n            summary_bits.append(f\"{error_count} error{'s' if error_count != 1 else ''}\")\n        if passed_count:\n            summary_bits.append(f\"{passed_count} passed\")\n        if skipped_count:\n            summary_bits.append(f\"{skipped_count} skipped\")\n\n        summary_str = \", \".join(summary_bits) if summary_bits else \"no tests run\"\n        print(\n            f\"=================== {summary_str} in {elapsed:.2f}s ===================\"\n        )\n\n    def startTest(self, test):\n        \"\"\"Called right before each test method.\"\"\"\n        super().startTest(test)\n        # Print a dot or some indicator\n        print(\".\", end=\"\", flush=True)\n\n    def addSuccess(self, test):\n        super().addSuccess(test)\n        self.results.append((self._test_id(test), \"passed\", None))\n\n    def addFailure(self, test, err):\n        super().addFailure(test, err)\n        self.results.append((self._test_id(test), \"failed\", err))\n\n    def addError(self, test, err):\n        super().addError(test, err)\n        self.results.append((self._test_id(test), \"error\", err))\n\n    def addSkip(self, test, reason):\n        super().addSkip(test, reason)\n        self.results.append((self._test_id(test), \"skipped\", reason))\n\n    def _print_traceback(self, err_info):\n        \"\"\"Helper to print the traceback like pytest does.\"\"\"\n        if isinstance(err_info, tuple) and len(err_info) == 3:\n            exc_type, exc_value, tb = err_info\n            traceback.print_exception(exc_type, exc_value, tb, file=sys.stdout)\n        else:\n            print(str(err_info))\n\n    def _test_id(self, test):\n        try:\n            return f\"{test.__class__.__module__}::{test.__class__.__name__}::{test._testMethodName}\"\n        except AttributeError:\n            # Fallback for _ErrorHolder objects\n            return f\"{test.__class__.__module__}::{test.__class__.__name__}\"\n\n\nclass PytestLikeRunner(unittest.TextTestRunner):\n    \"\"\"A custom TextTestRunner that uses the PytestLikeResult.\"\"\"\n\n    resultclass = PytestLikeResult\n\n    def run(self, test):\n        result = self._makeResult()\n        # Overriding run to ensure we call startTestRun/stopTestRun\n        result.startTestRun()\n        test(result)\n        result.stopTestRun()\n        return result\n\n\ndef main():\n    loader = unittest.TestLoader()\n    suite = loader.discover(\"r2e_tests\")  # discover tests in r2e_tests/\n    runner = PytestLikeRunner(verbosity=0)\n    result = runner.run(suite)\n    # Exit with code 0 if all tests passed/skipped, 1 if there were fails/errors\n    sys.exit(not result.wasSuccessful())\n\n\nif __name__ == \"__main__\":\n    main()\n"
    ],
    "test_file_names": [
        "test_1.py",
        "unittest_custom_runner.py"
    ],
    "setup_res_code": 0,
    "setup_res_stdout": "Starting Pillow installation attempts...\nVerifying Pillow installation...\n✅ Pillow installation successful!\nSuccessfully installed Pillow\n",
    "setup_res_stderr": "Using CPython 3.9.21\nCreating virtual environment at: .venv\nActivate with: source .venv/bin/activate\nResolved 12 packages in 15ms\nInstalled 12 packages in 135ms\n + coverage==7.6.10\n + exceptiongroup==1.2.2\n + iniconfig==2.0.0\n + packaging==24.2\n + pluggy==1.5.0\n + pyqt5==5.15.11\n + pyqt5-qt5==5.15.16\n + pyqt5-sip==12.16.1\n + pytest==8.3.4\n + pytest-cov==6.0.0\n + setuptools==75.8.0\n + tomli==2.2.1\nResolved 1 package in 1.09s\nPrepared 1 package in 14.37s\nInstalled 1 package in 2ms\n + pillow==3.3.0.dev0 (from file:///home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708)\n",
    "new_commit_res_code": 0,
    "new_commit_res_stdout": "============================= test session starts =============================\nplatform linux -- Python 3.9.21\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708\n...............\ncollected 15 items\n\n==================== short test summary info ====================\nPASSED test_1::CoreResampleAlphaCorrectTest::test_dirty_pixels_la\nPASSED test_1::CoreResampleAlphaCorrectTest::test_dirty_pixels_rgba\nSKIPPED test_1::CoreResampleAlphaCorrectTest::test_levels_la\nSKIPPED test_1::CoreResampleAlphaCorrectTest::test_levels_rgba\nPASSED test_1::CoreResampleConsistencyTest::test_32f\nPASSED test_1::CoreResampleConsistencyTest::test_32i\nPASSED test_1::CoreResampleConsistencyTest::test_8u\nPASSED test_1::TestImagingCoreResampleAccuracy::test_enlarge_bicubic\nPASSED test_1::TestImagingCoreResampleAccuracy::test_enlarge_bilinear\nPASSED test_1::TestImagingCoreResampleAccuracy::test_enlarge_lanczos\nPASSED test_1::TestImagingCoreResampleAccuracy::test_reduce_bicubic\nPASSED test_1::TestImagingCoreResampleAccuracy::test_reduce_bilinear\nPASSED test_1::TestImagingCoreResampleAccuracy::test_reduce_lanczos\nPASSED test_1::TestImagingResampleVulnerability::test_invalid_size\nPASSED test_1::TestImagingResampleVulnerability::test_overflow\n=================== 13 passed, 2 skipped in 0.06s ===================\n",
    "new_commit_res_stderr": "",
    "old_commit_res_code": 1,
    "old_commit_res_stdout": "============================= test session starts =============================\nplatform linux -- Python 3.9.21\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708\n...............\ncollected 15 items\n\n=================================== ERRORS =====================================\n__________ TestImagingCoreResampleAccuracy.test_enlarge_bicubic __________\nTraceback (most recent call last):\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 59, in testPartExecutor\n    yield\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 592, in run\n    self._callTestMethod(testMethod)\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 550, in _callTestMethod\n    method()\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/r2e_tests/test_1.py\", line 133, in test_enlarge_bicubic\n    case = self.make_case(mode, (4, 4), 0xe1)\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/r2e_tests/test_1.py\", line 51, in make_case\n    return Image.merge(mode, [case] *  len(mode))\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/PIL/Image.py\", line 2408, in merge\n    if getmodebands(mode) != len(bands) or \"*\" in mode:\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/PIL/Image.py\", line 340, in getmodebands\n    return len(ImageMode.getmode(mode).bands)\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/PIL/ImageMode.py\", line 48, in getmode\n    return _modes[mode]\nKeyError: 'La'\n__________ TestImagingCoreResampleAccuracy.test_enlarge_bilinear __________\nTraceback (most recent call last):\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 59, in testPartExecutor\n    yield\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 592, in run\n    self._callTestMethod(testMethod)\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 550, in _callTestMethod\n    method()\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/r2e_tests/test_1.py\", line 124, in test_enlarge_bilinear\n    case = self.make_case(mode, (2, 2), 0xe1)\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/r2e_tests/test_1.py\", line 51, in make_case\n    return Image.merge(mode, [case] *  len(mode))\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/PIL/Image.py\", line 2408, in merge\n    if getmodebands(mode) != len(bands) or \"*\" in mode:\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/PIL/Image.py\", line 340, in getmodebands\n    return len(ImageMode.getmode(mode).bands)\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/PIL/ImageMode.py\", line 48, in getmode\n    return _modes[mode]\nKeyError: 'La'\n__________ TestImagingCoreResampleAccuracy.test_enlarge_lanczos __________\nTraceback (most recent call last):\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 59, in testPartExecutor\n    yield\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 592, in run\n    self._callTestMethod(testMethod)\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 550, in _callTestMethod\n    method()\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/r2e_tests/test_1.py\", line 144, in test_enlarge_lanczos\n    case = self.make_case(mode, (6, 6), 0xe1)\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/r2e_tests/test_1.py\", line 51, in make_case\n    return Image.merge(mode, [case] *  len(mode))\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/PIL/Image.py\", line 2408, in merge\n    if getmodebands(mode) != len(bands) or \"*\" in mode:\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/PIL/Image.py\", line 340, in getmodebands\n    return len(ImageMode.getmode(mode).bands)\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/PIL/ImageMode.py\", line 48, in getmode\n    return _modes[mode]\nKeyError: 'La'\n__________ TestImagingCoreResampleAccuracy.test_reduce_bicubic __________\nTraceback (most recent call last):\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 59, in testPartExecutor\n    yield\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 592, in run\n    self._callTestMethod(testMethod)\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 550, in _callTestMethod\n    method()\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/r2e_tests/test_1.py\", line 103, in test_reduce_bicubic\n    case = self.make_case(mode, (12, 12), 0xe1)\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/r2e_tests/test_1.py\", line 51, in make_case\n    return Image.merge(mode, [case] *  len(mode))\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/PIL/Image.py\", line 2408, in merge\n    if getmodebands(mode) != len(bands) or \"*\" in mode:\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/PIL/Image.py\", line 340, in getmodebands\n    return len(ImageMode.getmode(mode).bands)\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/PIL/ImageMode.py\", line 48, in getmode\n    return _modes[mode]\nKeyError: 'La'\n__________ TestImagingCoreResampleAccuracy.test_reduce_bilinear __________\nTraceback (most recent call last):\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 59, in testPartExecutor\n    yield\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 592, in run\n    self._callTestMethod(testMethod)\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 550, in _callTestMethod\n    method()\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/r2e_tests/test_1.py\", line 94, in test_reduce_bilinear\n    case = self.make_case(mode, (8, 8), 0xe1)\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/r2e_tests/test_1.py\", line 51, in make_case\n    return Image.merge(mode, [case] *  len(mode))\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/PIL/Image.py\", line 2408, in merge\n    if getmodebands(mode) != len(bands) or \"*\" in mode:\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/PIL/Image.py\", line 340, in getmodebands\n    return len(ImageMode.getmode(mode).bands)\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/PIL/ImageMode.py\", line 48, in getmode\n    return _modes[mode]\nKeyError: 'La'\n__________ TestImagingCoreResampleAccuracy.test_reduce_lanczos __________\nTraceback (most recent call last):\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 59, in testPartExecutor\n    yield\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 592, in run\n    self._callTestMethod(testMethod)\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 550, in _callTestMethod\n    method()\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/r2e_tests/test_1.py\", line 113, in test_reduce_lanczos\n    case = self.make_case(mode, (16, 16), 0xe1)\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/r2e_tests/test_1.py\", line 51, in make_case\n    return Image.merge(mode, [case] *  len(mode))\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/PIL/Image.py\", line 2408, in merge\n    if getmodebands(mode) != len(bands) or \"*\" in mode:\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/PIL/Image.py\", line 340, in getmodebands\n    return len(ImageMode.getmode(mode).bands)\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f09067e45eeecdd85e8d379ddb7f2ea581e08708/PIL/ImageMode.py\", line 48, in getmode\n    return _modes[mode]\nKeyError: 'La'\n\n==================== short test summary info ====================\nPASSED test_1::CoreResampleAlphaCorrectTest::test_dirty_pixels_la\nPASSED test_1::CoreResampleAlphaCorrectTest::test_dirty_pixels_rgba\nSKIPPED test_1::CoreResampleAlphaCorrectTest::test_levels_la\nSKIPPED test_1::CoreResampleAlphaCorrectTest::test_levels_rgba\nPASSED test_1::CoreResampleConsistencyTest::test_32f\nPASSED test_1::CoreResampleConsistencyTest::test_32i\nPASSED test_1::CoreResampleConsistencyTest::test_8u\nERROR test_1::TestImagingCoreResampleAccuracy::test_enlarge_bicubic\nERROR test_1::TestImagingCoreResampleAccuracy::test_enlarge_bilinear\nERROR test_1::TestImagingCoreResampleAccuracy::test_enlarge_lanczos\nERROR test_1::TestImagingCoreResampleAccuracy::test_reduce_bicubic\nERROR test_1::TestImagingCoreResampleAccuracy::test_reduce_bilinear\nERROR test_1::TestImagingCoreResampleAccuracy::test_reduce_lanczos\nPASSED test_1::TestImagingResampleVulnerability::test_invalid_size\nPASSED test_1::TestImagingResampleVulnerability::test_overflow\n=================== 6 errors, 7 passed, 2 skipped in 0.02s ===================\n",
    "old_commit_res_stderr": ""
}
PIL/ImageMode.py Tests/test_image_resample.py
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** `'La'` Mode Not Recognized, Causing KeyError in Resample Accuracy Tests

**Description:**
When running the image resample accuracy tests, using the `'La'` mode results in a `KeyError`. This suggests that the `'La'` mode is not defined in the `ImageMode` configuration, preventing the tests from executing properly for images using this mode.

**Example Code:**
```python
mode = 'La'
image = Image.new(mode, (4, 4))
resized_image = image.resize((8, 8), Image.BICUBIC)
```

**Error Message:**
```
KeyError: 'La'
```

**Expected Behavior:**
The `'La'` mode should be defined within `ImageMode.py` so that images using this mode can be created and resized without any errors. This would allow the resample accuracy tests to run successfully for `'La'` mode images.

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### PIL/ImageMode.py
#
# The Python Imaging Library.
# $Id$
#
# standard mode descriptors
#
# History:
# 2006-03-20 fl   Added
#
# Copyright (c) 2006 by Secret Labs AB.
# Copyright (c) 2006 by Fredrik Lundh.
#
# See the README file for information on usage and redistribution.
#

# mode descriptor cache
_modes = {}


class ModeDescriptor(object):
    """Wrapper for mode strings."""

    def __init__(self, mode, bands, basemode, basetype):
        self.mode = mode
        self.bands = bands
        self.basemode = basemode
        self.basetype = basetype

    def __str__(self):
        return self.mode


def getmode(mode):
    """Gets a mode descriptor for the given mode."""
    if not _modes:
        # initialize mode cache
        from PIL import Image
        # core modes
        for m, (basemode, basetype, bands) in Image._MODEINFO.items():
            _modes[m] = ModeDescriptor(m, bands, basemode, basetype)
        # extra experimental modes
        _modes["LA"] = ModeDescriptor("LA", ("L", "A"), "L", "L")
        _modes["PA"] = ModeDescriptor("PA", ("P", "A"), "RGB", "L")
        # mapping modes
        _modes["I;16"] = ModeDescriptor("I;16", "I", "L", "L")
        _modes["I;16L"] = ModeDescriptor("I;16L", "I", "L", "L")
        _modes["I;16B"] = ModeDescriptor("I;16B", "I", "L", "L")
    return _modes[mode]

# End of file

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
[ISSUE]
**Title:** `'La'` Mode Not Recognized, Causing KeyError in Resample Accuracy Tests

**Description:**
When running the image resample accuracy tests, using the `'La'` mode results in a `KeyError`. This suggests that the `'La'` mode is not defined in the `ImageMode` configuration, preventing the tests from executing properly for images using this mode.

**Example Code:**
```python
mode = 'La'
image = Image.new(mode, (4, 4))
resized_image = image.resize((8, 8), Image.BICUBIC)
```

**Error Message:**
```
KeyError: 'La'
```

**Expected Behavior:**
The `'La'` mode should be defined within `ImageMode.py` so that images using this mode can be created and resized without any errors. This would allow the resample accuracy tests to run successfully for `'La'` mode images.

[/ISSUE]
{
    "CoreResampleAlphaCorrectTest.test_dirty_pixels_la": "PASSED",
    "CoreResampleAlphaCorrectTest.test_dirty_pixels_rgba": "PASSED",
    "CoreResampleConsistencyTest.test_32f": "PASSED",
    "CoreResampleConsistencyTest.test_32i": "PASSED",
    "CoreResampleConsistencyTest.test_8u": "PASSED",
    "TestImagingCoreResampleAccuracy.test_enlarge_bicubic": "PASSED",
    "TestImagingCoreResampleAccuracy.test_enlarge_bilinear": "PASSED",
    "TestImagingCoreResampleAccuracy.test_enlarge_lanczos": "PASSED",
    "TestImagingCoreResampleAccuracy.test_reduce_bicubic": "PASSED",
    "TestImagingCoreResampleAccuracy.test_reduce_bilinear": "PASSED",
    "TestImagingCoreResampleAccuracy.test_reduce_lanczos": "PASSED",
    "TestImagingResampleVulnerability.test_invalid_size": "PASSED",
    "TestImagingResampleVulnerability.test_overflow": "PASSED"
}
diff --git a/PIL/ImageMode.py b/PIL/ImageMode.py
index 957ef9c78..3587cec24 100644
--- a/PIL/ImageMode.py
+++ b/PIL/ImageMode.py
@@ -40,6 +40,7 @@ def getmode(mode):
             _modes[m] = ModeDescriptor(m, bands, basemode, basetype)
         # extra experimental modes
         _modes["LA"] = ModeDescriptor("LA", ("L", "A"), "L", "L")
+        _modes["La"] = ModeDescriptor("La", ("L", "a"), "L", "L")
         _modes["PA"] = ModeDescriptor("PA", ("P", "A"), "RGB", "L")
         # mapping modes
         _modes["I;16"] = ModeDescriptor("I;16", "I", "L", "L")

{"PIL/ImageMode.py": "#\n# The Python Imaging Library.\n# $Id$\n#\n# standard mode descriptors\n#\n# History:\n# 2006-03-20 fl   Added\n#\n# Copyright (c) 2006 by Secret Labs AB.\n# Copyright (c) 2006 by Fredrik Lundh.\n#\n# See the README file for information on usage and redistribution.\n#\n\n# mode descriptor cache\n_modes = {}\n\n\nclass ModeDescriptor(object):\n    \"\"\"Wrapper for mode strings.\"\"\"\n\n    def __init__(self, mode, bands, basemode, basetype):\n        self.mode = mode\n        self.bands = bands\n        self.basemode = basemode\n        self.basetype = basetype\n\n    def __str__(self):\n        return self.mode\n\n\ndef getmode(mode):\n    \"\"\"Gets a mode descriptor for the given mode.\"\"\"\n    if not _modes:\n        # initialize mode cache\n        from PIL import Image\n        # core modes\n        for m, (basemode, basetype, bands) in Image._MODEINFO.items():\n            _modes[m] = ModeDescriptor(m, bands, basemode, basetype)\n        # extra experimental modes\n        _modes[\"LA\"] = ModeDescriptor(\"LA\", (\"L\", \"A\"), \"L\", \"L\")\n        _modes[\"PA\"] = ModeDescriptor(\"PA\", (\"P\", \"A\"), \"RGB\", \"L\")\n        # mapping modes\n        _modes[\"I;16\"] = ModeDescriptor(\"I;16\", \"I\", \"L\", \"L\")\n        _modes[\"I;16L\"] = ModeDescriptor(\"I;16L\", \"I\", \"L\", \"L\")\n        _modes[\"I;16B\"] = ModeDescriptor(\"I;16B\", \"I\", \"L\", \"L\")\n    return _modes[mode]\n\n# End of file\n"}
A user will ask you to solve a task. You should first draft your thinking process (inner monologue). Then, generate the solution.

Your response format must follow the template below:
<think>
Your thoughts or/and draft, like working through an exercise on scratch paper. Be as casual and as long as you want until you are confident to generate a correct solution.
</think>
<solution>
Final solution presented to the user.
</solution>
system
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** `'La'` Mode Not Recognized, Causing KeyError in Resample Accuracy Tests

**Description:**
When running the image resample accuracy tests, using the `'La'` mode results in a `KeyError`. This suggests that the `'La'` mode is not defined in the `ImageMode` configuration, preventing the tests from executing properly for images using this mode.

**Example Code:**
```python
mode = 'La'
image = Image.new(mode, (4, 4))
resized_image = image.resize((8, 8), Image.BICUBIC)
```

**Error Message:**
```
KeyError: 'La'
```

**Expected Behavior:**
The `'La'` mode should be defined within `ImageMode.py` so that images using this mode can be created and resized without any errors. This would allow the resample accuracy tests to run successfully for `'La'` mode images.

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### PIL/ImageMode.py
#
# The Python Imaging Library.
# $Id$
#
# standard mode descriptors
#
# History:
# 2006-03-20 fl   Added
#
# Copyright (c) 2006 by Secret Labs AB.
# Copyright (c) 2006 by Fredrik Lundh.
#
# See the README file for information on usage and redistribution.
#

# mode descriptor cache
_modes = {}


class ModeDescriptor(object):
    """Wrapper for mode strings."""

    def __init__(self, mode, bands, basemode, basetype):
        self.mode = mode
        self.bands = bands
        self.basemode = basemode
        self.basetype = basetype

    def __str__(self):
        return self.mode


def getmode(mode):
    """Gets a mode descriptor for the given mode."""
    if not _modes:
        # initialize mode cache
        from PIL import Image
        # core modes
        for m, (basemode, basetype, bands) in Image._MODEINFO.items():
            _modes[m] = ModeDescriptor(m, bands, basemode, basetype)
        # extra experimental modes
        _modes["LA"] = ModeDescriptor("LA", ("L", "A"), "L", "L")
        _modes["PA"] = ModeDescriptor("PA", ("P", "A"), "RGB", "L")
        # mapping modes
        _modes["I;16"] = ModeDescriptor("I;16", "I", "L", "L")
        _modes["I;16L"] = ModeDescriptor("I;16L", "I", "L", "L")
        _modes["I;16B"] = ModeDescriptor("I;16B", "I", "L", "L")
    return _modes[mode]

# End of file

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
user