<commit_before>from math import pi
import cmath

import numpy as np
try:
    import cairocffi as cairo
except ImportError:
    import cairo

from pyqis.label import create_label

# we use the cielab color space so each hue has the same perceived intensity.
def cielchToRGB(l, c, h):
    # l and c go from 0 to 100
    # h is an angle in radians

    # based on http://www.easyrgb.com/index.php?X=MATH

    # convert to XYZ
    y = (l + 16) / 116.
    x = c * np.cos(h) / 500. + y
    z = y - c * np.sin(h) / 200.
    mp = lambda y: y * y * y if y > 0.206893 else (y - 16 / 116.) / 7.787
    y = mp(y)
    x = mp(x) * 0.95047
    z = mp(z) * 1.08883

    # convert to RGB
    r = x *  3.2406 + y * -1.5372 + z * -0.4986
    g = x * -0.9689 + y *  1.8758 + z *  0.0415
    b = x *  0.0557 + y * -0.2040 + z *  1.0570
    mp = lambda r: 1.055 * (r ** (1 / 2.4)) - 0.055 if r > 0.0031308 else 12.92 * r
    r = mp(r)
    g = mp(g)
    b = mp(b)

    # ensure it's in bounds and scale it to be between 0 and 255
    m = lambda v: max((min((1., v)), 0.))
    return (m(r), m(g), m(b))

def render_state(state, png_file=None, svg_file=None, use_color=True, label_format=None, states_per_row=4):
    """

    `svg_file` and `png_file` can be either a filename or a file object.
    """
    if png_file is None and svg_file is None:
        # there is nothing to do!
        return
<commit_msg>removed unnecessary import; formatting changes; docstring fix<commit_after>import cmath

import numpy as np
try:
    import cairocffi as cairo
except ImportError:
    import cairo

from pyqis.label import create_label

# we use the cielab color space so each hue has the same perceived intensity.
def cielchToRGB(l, c, h):
    # l and c go from 0 to 100
    # h is an angle in radians

    # based on http://www.easyrgb.com/index.php?X=MATH

    # convert to XYZ
    y = (l + 16) / 116.
    x = c * np.cos(h) / 500. + y
    z = y - c * np.sin(h) / 200.
    mp = lambda y: y * y * y if y > 0.206893 else (y - 16 / 116.) / 7.787
    y = mp(y)
    x = mp(x) * 0.95047
    z = mp(z) * 1.08883

    # convert to RGB
    r = x *  3.2406 + y * -1.5372 + z * -0.4986
    g = x * -0.9689 + y *  1.8758 + z *  0.0415
    b = x *  0.0557 + y * -0.2040 + z *  1.0570
    mp = lambda r: 1.055 * (r ** (1 / 2.4)) - 0.055 if r > 0.0031308 else 12.92 * r
    r = mp(r)
    g = mp(g)
    b = mp(b)

    # ensure it's in bounds and scale it to be between 0 and 255
    m = lambda v: max((min((1., v)), 0.))
    return (m(r), m(g), m(b))

def render_state(state, png_file=None, svg_file=None,
                 use_color=True, label_format=None, states_per_row=4):
    """Render a state to either png or svg format (or both)

    `svg_file` and `png_file` can be either a filename or a binary file object.
    """
    if png_file is None and svg_file is None:
        # there is nothing to do!
        return

{'fraction_non_alphanumeric': 0.13082811412665274, 'fraction_numerical': 0.08211551844119694, 'mean_word_length': 2.094725511302476, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5356910', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1136, 'n_words': 408}