Beispiel #1
0
def test_resample_rmd(make_data_path):
    infile = make_data_path('gro_delta.txt')
    ui.load_ascii_with_errors(1, infile, delta=True, func=rms)
    base = ui.get_data(1)
    data = Data1DAsymmetricErrs(2, base.x, base.y, base.elo, base.ehi,
                                base.staterror, base.syserror)
    resample_data(data, RESAMPLE_BENCH, RESULTS_BENCH_RMS)
Beispiel #2
0
 def test_AsymmetricErrors_resample_avg(self):
     ui.load_ascii_with_errors(1, self.gro_delta_fname, delta=True)
     tmp = ui.get_data(1)
     data = Data1DAsymmetricErrs(1, tmp.x, tmp.y, tmp.elo,
                                 tmp.ehi, tmp.staterror, tmp.syserror)
     self.resample_data(data, self._resample_bench,
                        self._results_bench_avg)
Beispiel #3
0
def test_constructor_rms(make_data_path):
    infile = make_data_path('gro_delta.txt')
    ui.load_ascii_with_errors(1, infile, delta=True, func=rms)
    base = ui.get_data(1)
    data = Data1DAsymmetricErrs(2, base.x, base.y, base.elo, base.ehi,
                                base.staterror, base.syserror)
    fit_asymmetric_err(RESULTS_BENCH_RMS, data)
Beispiel #4
0
 def test_AsymmetricErrs_rms(self):
     ui.load_ascii_with_errors(1, self.gro_delta_fname, func=self.rms,
                                  delta=True)
     tmp = ui.get_data(1)
     data = Data1DAsymmetricErrs(2, tmp.x, tmp.y, tmp.elo,
                                 tmp.ehi, tmp.staterror, tmp.syserror)
     self.fit_asymmetric_err(self._results_bench_rms, data)        
Beispiel #5
0
def test_zero_case():
    """Check what happens when values can be near -1. See #740"""

    xs = np.arange(1, 6)
    ys = np.asarray([0.5, -0.5, 0.3, 0.2, -0.1])
    dyl = np.asarray([2, 2, 2, 2, 2])
    dyh = np.asarray([2, 2, 2, 2, 2])

    data = Data1DAsymmetricErrs('zero', xs, ys, dyl, dyh)
    mdl = Const1D('flat')

    bestfit = Fit(data, mdl).fit()

    rd = ReSampleData(data, mdl)

    # Both approaches should give the same results (as setting
    # niter explicitly).
    #
    # res = rd.call(niter=10, seed=47)
    res = rd(niter=10, seed=47)

    # Technically this depends on random chance, but it is rather
    # unlikely we'd get 10 -1 values here. Relax the -1 value and
    # just ensure we have more than 1 unique value here (can probably
    # assert nvs == 10 but technically we allow repeated values).
    #
    vs = np.unique(res['flat.c0'])
    nvs = len(vs)
    assert nvs > 1

    # Minimal testing of the other return values. We do assume that
    # we have not found a better fit than the fit.
    #
    samples = res['samples']
    stats = res['statistic']
    assert samples.shape == (10, 5)
    assert stats.shape == (10, )
    assert (stats >= bestfit.statval).all()