Example #1
0
def test_calculation():
    chargeres = ChargeResolutionCalculator()
    measured = np.array([3.5, 2.7])
    true = 3
    n = measured.size

    sum_ = np.sum(np.power(measured - true, 2))
    assert_almost_equal(sum_, 0.34, 3)
    assert_almost_equal(chargeres.rmse_abs(sum_, n), 0.412, 3)
    assert_almost_equal(chargeres.rmse(true, sum_, n), 0.137, 3)
    assert_almost_equal(chargeres.charge_res_abs(true, sum_, n), 1.780, 3)
    assert_almost_equal(chargeres.charge_res(true, sum_, n), 0.593, 3)

    assert chargeres.rmse_abs(sum_, n) == chargeres.rmse(true, sum_, n) * true
    assert (chargeres.charge_res_abs(
        true, sum_, n) == chargeres.charge_res(true, sum_, n) * true)
def test_calculation():
    chargeres = ChargeResolutionCalculator()
    measured = np.array([3.5, 2.7])
    true = 3
    n = measured.size

    sum_ = np.sum(np.power(measured - true, 2))
    assert_almost_equal(sum_, 0.34, 3)
    assert_almost_equal(chargeres.rmse_abs(sum_, n), 0.412, 3)
    assert_almost_equal(chargeres.rmse(true, sum_, n), 0.137, 3)
    assert_almost_equal(chargeres.charge_res_abs(true, sum_, n), 1.780, 3)
    assert_almost_equal(chargeres.charge_res(true, sum_, n), 0.593, 3)

    assert chargeres.rmse_abs(sum_, n) == chargeres.rmse(true, sum_, n) * true
    assert (chargeres.charge_res_abs(true, sum_, n) ==
            chargeres.charge_res(true, sum_, n) * true)
def test_result_mc_true():
    chargeres = ChargeResolutionCalculator()
    measured = np.array([3.5, 2.7])
    true = 3
    n = measured.size
    sum_ = np.sum(np.power(measured - true, 2))

    chargeres.add(0, true, measured)
    df_p, df_c = chargeres.finish()
    assert (df_p['charge_resolution'].values[0] ==
            chargeres.charge_res(true, sum_, n))
    assert (df_p['charge_resolution_abs'].values[0] ==
            chargeres.charge_res_abs(true, sum_, n))
Example #4
0
def test_result_mc_true():
    chargeres = ChargeResolutionCalculator()
    measured = np.array([3.5, 2.7])
    true = 3
    n = measured.size
    sum_ = np.sum((measured - true)**2)

    chargeres.add(0, true, measured)
    df_p, df_c = chargeres.finish()
    assert df_p["charge_resolution"].values[0] == chargeres.charge_res(
        true, sum_, n)
    assert df_p["charge_resolution_abs"].values[0] == chargeres.charge_res_abs(
        true, sum_, n)