<commit_before>
import BaseDomsHandler
import ResultsStorage
import string
from cStringIO import StringIO
import matplotlib.mlab as mlab

from multiprocessing import Process, Manager

import numpy as np
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use('Agg')




PARAMETER_TO_FIELD = {
    "sst": "sea_water_temperature",
    "sss": "sea_water_salinity"
}

PARAMETER_TO_UNITS = {
    "sst": "($^\circ$C)",
    "sss": "(g/L)"
}

class DomsHistogramPlotQueryResults(BaseDomsHandler.DomsQueryResults):

    def __init__(self,  x, parameter, primary, secondary, args=None, bounds=None, count=None, details=None, computeOptions=None, executionId=None, plot=None):
        BaseDomsHandler.DomsQueryResults.__init__(self, results=x, args=args, details=details, bounds=bounds, count=count, computeOptions=computeOptions, executionId=executionId)
        self.__primary = primary
        self.__secondary = secondary
        self.__x = x
        self.__parameter = parameter
        self.__plot = plot

    def toImage(self):
        return self.__plot


def render(d, x, primary, secondary, parameter, norm_and_curve=False):

    fig, ax = plt.subplots()
    fig.suptitle(string.upper("%s vs. %s" % (primary, secondary)), fontsize=14, fontweight='bold')



    n, bins, patches = plt.hist(x, 50, normed=norm_and_curve, facecolor='green', alpha=0.75)


    if norm_and_curve:
        mean = np.mean(x)
        variance = np.var(x)
        sigma = np.sqrt(variance)
        y = mlab.normpdf(bins, mean, sigma)
        l = plt.plot(bins, y, 'r--', linewidth=1)

    ax.set_title('n = %d' % len(x))

    units = PARAMETER_TO_UNITS[parameter] if parameter in PARAMETER_TO_UNITS else PARAMETER_TO_UNITS["sst"]
    ax.set_xlabel("Difference %s" % (units))
    ax.set_ylabel("Frequency")<commit_msg>Updated DOMS histogram axis labels<commit_after>
import BaseDomsHandler
import ResultsStorage
import string
from cStringIO import StringIO
import matplotlib.mlab as mlab

from multiprocessing import Process, Manager

import numpy as np
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use('Agg')




PARAMETER_TO_FIELD = {
    "sst": "sea_water_temperature",
    "sss": "sea_water_salinity"
}

PARAMETER_TO_UNITS = {
    "sst": "($^\circ$C)",
    "sss": "(g/L)"
}

class DomsHistogramPlotQueryResults(BaseDomsHandler.DomsQueryResults):

    def __init__(self,  x, parameter, primary, secondary, args=None, bounds=None, count=None, details=None, computeOptions=None, executionId=None, plot=None):
        BaseDomsHandler.DomsQueryResults.__init__(self, results=x, args=args, details=details, bounds=bounds, count=count, computeOptions=computeOptions, executionId=executionId)
        self.__primary = primary
        self.__secondary = secondary
        self.__x = x
        self.__parameter = parameter
        self.__plot = plot

    def toImage(self):
        return self.__plot


def render(d, x, primary, secondary, parameter, norm_and_curve=False):

    fig, ax = plt.subplots()
    fig.suptitle(string.upper("%s vs. %s" % (primary, secondary)), fontsize=14, fontweight='bold')



    n, bins, patches = plt.hist(x, 50, normed=norm_and_curve, facecolor='green', alpha=0.75)


    if norm_and_curve:
        mean = np.mean(x)
        variance = np.var(x)
        sigma = np.sqrt(variance)
        y = mlab.normpdf(bins, mean, sigma)
        l = plt.plot(bins, y, 'r--', linewidth=1)

    ax.set_title('n = %d' % len(x))

    units = PARAMETER_TO_UNITS[parameter] if parameter in PARAMETER_TO_UNITS else PARAMETER_TO_UNITS["sst"]
    ax.set_xlabel("%s - %s %s" % (primary, secondary, units))

    if norm_and_curve:
        ax.set_ylabel("Probability per unit difference")
    else:
        ax.set_ylabel("Frequency")

{'fraction_non_alphanumeric': 0.12004287245444802, 'fraction_numerical': 0.004287245444801715, 'mean_word_length': 3.911842105263158, 'pattern_counts': {'":': 8, '<': 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': '7054093', 'n_tokens_mistral': 1277, 'n_tokens_neox': 1238, 'n_words': 283}