<commit_before>import pylab
import matplotlib
from matplotlib import pyplot
import sys
import os

from Utils import getGoldenRatioDimensions

class PlotLayout(object):
    def __init__(self):
        self.groupedPlots = {}
        self.plots = []
        self.groupOrder = None

        self.width = 1
        self.plotParams = None

        self.dimensions = None
        self.figdimensions = None

        self.figLegendLoc = None
        self.figLegendCols = None

        self.rcParams = None
        
    def __setRCParam(self, param, value):
        if self.rcParams is None:
            self.rcParams = {}

        self.rcParams[param] = value

    def useLatexLabels(self):
        print >>sys.stderr, "WARNING: Using LaTeX labels requires dvipng and ghostscript"
        self.__setRCParam("font.family", "serif")
        self.__setRCParam("font.serif", "Times, Palatino, New Century Schoolbook, Bookman, Computer Modern Roman")
        self.__setRCParam("font.sans-serif", "Helvetica, Avant Garde, Computer Modern Sans serif")
        self.__setRCParam("font.cursive", "Zapf Chancery")
        self.__setRCParam("font.monospace", "Courier, Computer Modern Typewriter")
        self.__setRCParam("text.usetex", True)

    # def useStandardFont(self):
    #     self.__setRCParam("font.family", "serif")
    #     self.__setRCParam("font.style", "normal")
    #     self.__setRCParam("font.variant", "normal")
    #     self.__setRCParam("font.weight", "normal")
    #     self.__setRCParam("font.stretch", "normal")
        
    def setAxesLabelSize(self, size):
        self.__setRCParam("axes.labelsize", size)

    def setXTickLabelSize(self, size):
        self.__setRCParam("xtick.labelsize", size)

    def setYTickLabelSize(self, size):
        self.__setRCParam("ytick.labelsize", size)

    def setLegendLabelSize(self, size):
        self.__setRCParam("legend.fontsize", size)

    def setWidth(self, width):
        self.width = int(width)

    def hasFigLegend(self, loc="best", numcols=1):
        self.figLegendLoc = loc
        self.figLegendCols = numcols

    def addPlot(self, plot, grouping=None):
        if grouping == None:
            self.plots.append(plot)
        else:
            if grouping not in self.groupedPlots:
                self.groupedPlots[grouping] = []

            self.groupedPlots[grouping].append(plot)

    def setGroupOrder(self, groupOrder):
        self.groupOrder = groupOrder

    def setPlotDimensions(self, x, y):
        self.dimensions = (x,y)

    def setFigureDimensions(self, x, y):<commit_msg>Making hasLegend/hasFigLegend consistent w/columns vs numcols. Added deprecation warning<commit_after>import pylab
import matplotlib
from matplotlib import pyplot
import sys
import os
import warnings

from Utils import getGoldenRatioDimensions

class PlotLayout(object):
    def __init__(self):
        self.groupedPlots = {}
        self.plots = []
        self.groupOrder = None

        self.width = 1
        self.plotParams = None

        self.dimensions = None
        self.figdimensions = None

        self.figLegendLoc = None
        self.figLegendCols = None

        self.rcParams = None
        
    def __setRCParam(self, param, value):
        if self.rcParams is None:
            self.rcParams = {}

        self.rcParams[param] = value

    def useLatexLabels(self):
        print >>sys.stderr, "WARNING: Using LaTeX labels requires dvipng and ghostscript"
        self.__setRCParam("font.family", "serif")
        self.__setRCParam("font.serif", "Times, Palatino, New Century Schoolbook, Bookman, Computer Modern Roman")
        self.__setRCParam("font.sans-serif", "Helvetica, Avant Garde, Computer Modern Sans serif")
        self.__setRCParam("font.cursive", "Zapf Chancery")
        self.__setRCParam("font.monospace", "Courier, Computer Modern Typewriter")
        self.__setRCParam("text.usetex", True)

    # def useStandardFont(self):
    #     self.__setRCParam("font.family", "serif")
    #     self.__setRCParam("font.style", "normal")
    #     self.__setRCParam("font.variant", "normal")
    #     self.__setRCParam("font.weight", "normal")
    #     self.__setRCParam("font.stretch", "normal")
        
    def setAxesLabelSize(self, size):
        self.__setRCParam("axes.labelsize", size)

    def setXTickLabelSize(self, size):
        self.__setRCParam("xtick.labelsize", size)

    def setYTickLabelSize(self, size):
        self.__setRCParam("ytick.labelsize", size)

    def setLegendLabelSize(self, size):
        self.__setRCParam("legend.fontsize", size)

    def setWidth(self, width):
        self.width = int(width)

    def hasFigLegend(self, loc="best", columns=1, numcols=None):
        if numcols is not None:
            # hasLegend uses columns, rather than numcols.
            # trying to make this consistent.
            # this should catch named parameter usage
            columns = numcols
            warnings.warn("numcols deprecated for hasFigLegend", Warning)

        self.figLegendLoc = loc
        self.figLegendCols = numcols

    def addPlot(self, plot, grouping=None):
        if grouping == None:
            self.plots.append(plot)
        else:
            if grouping not in self.groupedPlots:
                self.groupedPlots[grouping] = []

            self.groupedPlots[grouping].append(plot)

    def setGroupOrder(self, groupOrder):
        self.groupOrder = groupOrder

    def setPlotDimensions(self, x, y):
        self.dimensions = (x,y)

    def setFigureDimensions(self, x, y):
{'fraction_non_alphanumeric': 0.10700706137968495, 'fraction_numerical': 0.0007242440702516748, 'mean_word_length': 2.692513368983957, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7408977', 'n_tokens_mistral': 1714, 'n_tokens_neox': 1630, 'n_words': 373}