<commit_before>import logging
import numpy as np
from matplotlib import use
use("Qt5Agg")  # should be called before pyplot
import matplotlib.pyplot as plt

__all__ = ["plot_one_peak"]


def plot_one_peak(peak, title=None, norm=True, begin=None, end=None):
    plt.clf()
    plt.xlabel("Depth in water [mm]")
    plt.ylabel("Relative dose")
    if norm:
        plt.ylim([0, 1])
    if title:
        plt.title(title)
    if begin and end:
        plt.plot([begin, begin], [0, 1])
        plt.plot([end, end], [0, 1])
    plt.plot(peak[0], peak[1])
    plt.show()


def do_some_magic(sum_peak, begin, end):
    # profile
    domain = sum_peak[0]
    values = sum_peak[1]
    middle = (begin + end) / 2
    width = end - begin
    logging.debug("approx middle = %f\napprox width = %f" % (middle, width))
    section = [middle - width / 4, middle + width / 4]
    section_coords = [(np.abs(domain - section[0])).argmin(),
                      (np.abs(domain - section[1])).argmin()]
    norm = np.mean(values[section_coords[0]:section_coords[1]])
    logging.debug("Calculated norm = %f" % norm)
    values /= norm

    # draw plots
    plt.plot(domain, values)
    plt.plot((0, domain[-1]), (1.04, 1.04))
    plt.plot((0, domain[-1]), (1.02, 1.02))
    plt.plot((0, domain[-1]), (1, 1))<commit_msg>added grid to plots<commit_after>import logging
import numpy as np
from matplotlib import use
use("Qt5Agg")  # should be called before pyplot
import matplotlib.pyplot as plt

__all__ = ["plot_one_peak"]


def plot_one_peak(peak, title=None, norm=True, begin=None, end=None):
    plt.clf()
    plt.xlabel("Depth in water [mm]")
    plt.ylabel("Relative dose")
    if norm:
        plt.ylim([0, 1])
    if title:
        plt.title(title)
    if begin and end:
        plt.plot([begin, begin], [0, 1])
        plt.plot([end, end], [0, 1])
        plt.grid(True)
    plt.plot(peak[0], peak[1])
    plt.show()


def do_some_magic(sum_peak, begin, end):
    # profile
    domain = sum_peak[0]
    values = sum_peak[1]
    middle = (begin + end) / 2
    width = end - begin
    logging.debug("approx middle = %f\napprox width = %f" % (middle, width))
    section = [middle - width / 4, middle + width / 4]
    section_coords = [(np.abs(domain - section[0])).argmin(),
                      (np.abs(domain - section[1])).argmin()]
    norm = np.mean(values[section_coords[0]:section_coords[1]])
    logging.debug("Calculated norm = %f" % norm)
    values /= norm

    # draw plots
    plt.plot(domain, values)
    plt.plot((0, domain[-1]), (1.04, 1.04))
    plt.plot((0, domain[-1]), (1.02, 1.02))
    plt.plot((0, domain[-1]), (1, 1))
{'fraction_non_alphanumeric': 0.168, 'fraction_numerical': 0.02895238095238095, 'mean_word_length': 2.8391812865497075, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1251787', 'n_tokens_mistral': 999, 'n_tokens_neox': 945, 'n_words': 235}