Exemplo n.º 1
0
def test_image_plot_ratio_callable():
    """
    Test plot_pull by comparing against a reference image generated via
    `pytest --mpl-generate-path=tests/baseline`
    """

    np.random.seed(42)

    hist_1 = Hist(
        axis.Regular(50,
                     -5,
                     5,
                     name="X",
                     label="x [units]",
                     underflow=False,
                     overflow=False)).fill(np.random.normal(size=1000))

    def model(x, a=1 / np.sqrt(2 * np.pi), x0=0, sigma=1, offset=0):
        return a * np.exp(-((x - x0)**2) / (2 * sigma**2)) + offset

    fig = plt.figure()

    assert hist_1.plot_ratio(model,
                             eb_color="black",
                             fp_color="blue",
                             ub_color="lightblue")

    return fig
Exemplo n.º 2
0
def test_image_plot_ratio_hist():
    """
    Test plot_pull by comparing against a reference image generated via
    `pytest --mpl-generate-path=tests/baseline`
    """

    np.random.seed(42)

    hist_1 = Hist(
        axis.Regular(50,
                     -5,
                     5,
                     name="X",
                     label="x [units]",
                     underflow=False,
                     overflow=False)).fill(np.random.normal(size=1000))
    hist_2 = Hist(
        axis.Regular(50,
                     -5,
                     5,
                     name="X",
                     label="x [units]",
                     underflow=False,
                     overflow=False)).fill(np.random.normal(size=1700))

    fig = plt.figure()

    assert hist_1.plot_ratio(hist_2,
                             rp_num_label="numerator",
                             rp_denom_label="denominator")

    return fig