<commit_before>"""Functions that alter the matplotlib rc dictionary on the fly."""
import contextlib
from numpy import isreal
import matplotlib as mpl
from seaborn import utils


def set(context="notebook", style="darkgrid", palette="deep", font="Arial", gridweight="medium"):
    """Set new RC params in one step."""
    set_axes_style(style, context, font=font, gridweight=gridweight)
    set_color_palette(palette)

def reset_defaults():
    """Restore all RC params to default settings."""
    mpl.rcParams.update(mpl.rcParamsDefault)


def set_axes_style(style, context, font="Arial", gridweight="medium"):
    """Set the axis style.

    Parameters
    ----------
    style : darkgrid | whitegrid | nogrid | ticks
        Style of axis background.
    context: notebook | talk | paper | poster
        Intended context for resulting figures.
    font : matplotlib font spec
        Font to use for text in the figures.
    gridweight : heavy | medium | light
        Width of the grid lines. None

    """

    # Validate the arguments
    if not {"darkgrid", "whitegrid", "nogrid", "ticks"} & {style}:
        raise ValueError("Style %s not recognized" % style)

    if not {"notebook", "talk", "paper", "poster"} & {context}:
        raise ValueError("Context %s is not recognized" % context)

    if not isreal(gridweight) and \
      (not {"extra heavy", "heavy", "medium", "light"} & {gridweight}):
        raise ValueError("Gridweight %s is not recognized" % gridweight)

    # Determine the axis parameters
    # -----------------------------

    # Turn ticks off; they get turned back on in 'ticks' style
    mpl.rc("xtick.major", size=0)
    mpl.rc("ytick.major", size=0)
    mpl.rc("xtick.minor", size=0)
    mpl.rc("ytick.minor", size=0)

    # select grid line width:
    gridweights = {
        'extra heavy': 1.5,
        'heavy': 1.1,
        'medium': 0.8,
        'light': 0.5,
    }
    if isreal(gridweight):
        glw = gridweight
    else:
        glw = gridweights[gridweight]

    if style == "darkgrid":
        lw = .8 if context == "paper" else 1.5
        ax_params = {"axes.facecolor": "#EAEAF2",
                     "axes.edgecolor": "white",
                     "axes.linewidth": 0,
                     "axes.grid": True,
                     "axes.axisbelow": True,
                     "grid.color": "w",
                     "grid.linestyle": "-",
                     "grid.linewidth": lw}

    elif style == "whitegrid":
        lw = 1.0 if context == "paper" else 1.7
        ax_params = {"axes.facecolor": "white",
                     "axes.edgecolor": "#CCCCCC",
                     "axes.linewidth": lw + .2,
                     "axes.grid": True,
                     "axes.axisbelow": True,
                     "grid.color": "#DDDDDD",
                     "grid.linestyle": "-",
                     "grid.linewidth": glw}

    elif style == "nogrid":
        ax_params = {"axes.grid": False,
                     "axes.facecolor": "white",
                     "axes.edgecolor": "black",
                     "axes.linewidth": 1}

    elif style == "ticks":
        ticksize = 3. if context == "paper" else 6.
        tickwidth = .5 if context == "paper" else 1
        ax_params = {"axes.grid": False,
                     "axes.facecolor": "white",
                     "axes.edgecolor": "black",
                     "axes.linewidth": 1,
                     "xtick.direction": "out",
                     "ytick.direction": "out",
                     "xtick.major.width": tickwidth,
                     "ytick.major.width": tickwidth,
                     "xtick.minor.width": tickwidth,
                     "xtick.minor.width": tickwidth,
                     "xtick.major.size": ticksize,<commit_msg>fixed math for lineweights and the set_axis_style docstring<commit_after>"""Functions that alter the matplotlib rc dictionary on the fly."""
import contextlib
from numpy import isreal
import matplotlib as mpl
from seaborn import utils


def set(context="notebook", style="darkgrid", palette="deep", font="Arial", gridweight="medium"):
    """Set new RC params in one step."""
    set_axes_style(style, context, font=font, gridweight=gridweight)
    set_color_palette(palette)

def reset_defaults():
    """Restore all RC params to default settings."""
    mpl.rcParams.update(mpl.rcParamsDefault)


def set_axes_style(style, context, font="Arial", gridweight="medium"):
    """Set the axis style.

    Parameters
    ----------
    style : darkgrid | whitegrid | nogrid | ticks
        Style of axis background.
    context: notebook | talk | paper | poster
        Intended context for resulting figures.
    font : matplotlib font spec
        Font to use for text in the figures.
    gridweight : extra heavy | heavy | medium (default) | light
        Width of the grid lines. None

    """

    # Validate the arguments
    if not {"darkgrid", "whitegrid", "nogrid", "ticks"} & {style}:
        raise ValueError("Style %s not recognized" % style)

    if not {"notebook", "talk", "paper", "poster"} & {context}:
        raise ValueError("Context %s is not recognized" % context)

    if not isreal(gridweight) and \
      (not {"extra heavy", "heavy", "medium", "light"} & {gridweight}):
        raise ValueError("Gridweight %s is not recognized" % gridweight)

    # Determine the axis parameters
    # -----------------------------

    # Turn ticks off; they get turned back on in 'ticks' style
    mpl.rc("xtick.major", size=0)
    mpl.rc("ytick.major", size=0)
    mpl.rc("xtick.minor", size=0)
    mpl.rc("ytick.minor", size=0)

    # select grid line width:
    gridweights = {
        'extra heavy': 1.5,
        'heavy': 1.1,
        'medium': 0.8,
        'light': 0.5,
    }
    if isreal(gridweight):
        glw = gridweight
    else:
        glw = gridweights[gridweight]

    if style == "darkgrid":
        lw = .8 if context == "paper" else 1.5
        ax_params = {"axes.facecolor": "#EAEAF2",
                     "axes.edgecolor": "white",
                     "axes.linewidth": 0,
                     "axes.grid": True,
                     "axes.axisbelow": True,
                     "grid.color": "w",
                     "grid.linestyle": "-",
                     "grid.linewidth": lw}

    elif style == "whitegrid":
        lw = 1.0 if context == "paper" else 1.7
        ax_params = {"axes.facecolor": "white",
                     "axes.edgecolor": "#CCCCCC",
                     "axes.linewidth": lw,
                     "axes.grid": True,
                     "axes.axisbelow": True,
                     "grid.color": "#DDDDDD",
                     "grid.linestyle": "-",
                     "grid.linewidth": glw}

    elif style == "nogrid":
        ax_params = {"axes.grid": False,
                     "axes.facecolor": "white",
                     "axes.edgecolor": "black",
                     "axes.linewidth": 1}

    elif style == "ticks":
        ticksize = 3. if context == "paper" else 6.
        tickwidth = .5 if context == "paper" else 1
        ax_params = {"axes.grid": False,
                     "axes.facecolor": "white",
                     "axes.edgecolor": "black",
                     "axes.linewidth": 1,
                     "xtick.direction": "out",
                     "ytick.direction": "out",
                     "xtick.major.width": tickwidth,
                     "ytick.major.width": tickwidth,
                     "xtick.minor.width": tickwidth,
                     "xtick.minor.width": tickwidth,
                     "xtick.major.size": ticksize,
{'fraction_non_alphanumeric': 0.14037626628075253, 'fraction_numerical': 0.00723589001447178, 'mean_word_length': 1.810351201478743, 'pattern_counts': {'":': 70, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2080423', 'n_tokens_mistral': 2279, 'n_tokens_neox': 2112, 'n_words': 608}