<commit_before># -*- coding: utf-8 -*-
#
import os
import matplotlib as mpl
from matplotlib.backends import backend_agg
from PIL import Image


def draw_quadmesh(data, obj):
    '''Returns the PGFPlots code for an graphics environment holding a
       rendering of the object.
    '''
    content = []

    # Generate file name for current object
    if 'img number' not in data.keys():
        data['img number'] = 0

    filename = os.path.join(data['output dir'],
                            '%s_img%03d.png' % (data['base name'],
                                                data['img number'])
                            )
    data['img number'] = data['img number'] + 1

    # Get the dpi for rendering and store the original dpi of the figure
    if data['dpi']:
        dpi = data['dpi']
    else:
        dpi = mpl.rcParams['savefig.dpi']
    fig_dpi = obj.figure.get_dpi()
    obj.figure.set_dpi(dpi)

    # Render the object and save as png file
    cbox = obj.get_clip_box()
    width = int(round(cbox.extents[2]))
    height = int(round(cbox.extents[3]))
    ren = backend_agg.RendererAgg(width, height, dpi)
    obj.draw(ren)

    # Generate a image from the render buffer
    image = Image.frombuffer('RGBA', ren.get_canvas_width_height(),
                             ren.buffer_rgba(), 'raw', 'RGBA', 0, 1)
    # Crop the image to the actual content (removing the the regions otherwise
    # used for axes, etc.)
    # 'image.crop' expects the crop box to specify the left, upper, right, and
    # lower pixel. 'cbox.extents' gives the left, lower, right, and upper pixel.
    box = (int(round(cbox.extents[0])),
           0,
           int(round(cbox.extents[2])),
           int(round(cbox.extents[3] - cbox.extents[1])))<commit_msg>Code style fixes to pass linthub checks<commit_after># -*- coding: utf-8 -*-
#
import os
import matplotlib as mpl
from matplotlib.backends import backend_agg
from PIL import Image


def draw_quadmesh(data, obj):
    '''Returns the PGFPlots code for an graphics environment holding a
       rendering of the object.
    '''
    content = []

    # Generate file name for current object
    if 'img number' not in data.keys():
        data['img number'] = 0

    filename = os.path.join(data['output dir'],
                            '%s_img%03d.png' % (data['base name'],
                                                data['img number'])
                            )
    data['img number'] = data['img number'] + 1

    # Get the dpi for rendering and store the original dpi of the figure
    if data['dpi']:
        dpi = data['dpi']
    else:
        dpi = mpl.rcParams['savefig.dpi']
    fig_dpi = obj.figure.get_dpi()
    obj.figure.set_dpi(dpi)

    # Render the object and save as png file
    cbox = obj.get_clip_box()
    width = int(round(cbox.extents[2]))
    height = int(round(cbox.extents[3]))
    ren = backend_agg.RendererAgg(width, height, dpi)
    obj.draw(ren)

    # Generate a image from the render buffer
    image = Image.frombuffer('RGBA', ren.get_canvas_width_height(),
                             ren.buffer_rgba(), 'raw', 'RGBA', 0, 1)
    # Crop the image to the actual content (removing the the regions otherwise
    # used for axes, etc.)
    # 'image.crop' expects the crop box to specify the left, upper, right, and
    # lower pixel. 'cbox.extents' gives the left, lower, right, and upper
    # pixel.
    box = (int(round(cbox.extents[0])),
           0,
           int(round(cbox.extents[2])),
           int(round(cbox.extents[3] - cbox.extents[1])))
{'fraction_non_alphanumeric': 0.11928934010152284, 'fraction_numerical': 0.007896221094190638, 'mean_word_length': 2.2903525046382187, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5496057', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1097, 'n_words': 335}