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)
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)
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)
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)
def test_gro_delta_rms(self): ui.load_ascii_with_errors(1, self.gro_delta_fname, func=self.rms, delta=True) data = ui.get_data(1) self.fit_asymmetric_err(self._results_bench_rms, data)
def test_ui(make_data_path): infile = make_data_path('gro_delta.txt') ui.load_ascii_with_errors(1, infile, delta=True) ui.set_stat('leastsq') ui.set_model('powlaw1d.p1') ui.fit() sample = ui.resample_data(1, 10, seed=123) for p in ['p1.gamma', 'p1.ampl']: assert sample[p] == pytest.approx(RESAMPLE_BENCH_10[p], rel=1e-4)
def test_warning(make_data_path): infile = make_data_path('gro.txt') ui.load_ascii_with_errors(1, infile) powlaw1d = PowLaw1D('p1') ui.set_model(powlaw1d) ui.fit() with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") ui.resample_data(1, 3) assert len(w) == 0
def test_warning(self): ui.load_ascii_with_errors(1, self.gro_fname) data = ui.get_data(1) powlaw1d = PowLaw1D('p1') ui.set_model(powlaw1d) fit = Fit(data, powlaw1d) results = fit.fit() with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") ui.resample_data(1, 3) assert len(w) == 0
def test_ui(self, tol=1.0e-3): # from shepa.astro.ui import * ui.load_ascii_with_errors(1, self.gro_delta_fname, delta=True) ui.set_stat('leastsq') ui.set_model('powlaw1d.p1') ui.fit() sample = ui.resample_data(1, 10, seed=123) self.assertEqualWithinTol(self._resample_bench_10['p1.gamma'], sample['p1.gamma']) self.assertEqualWithinTol(self._resample_bench_10['p1.ampl'], sample['p1.ampl'])
def test_load_ascii_rms(filename, delta, make_data_path): infile = make_data_path(filename) ui.load_ascii_with_errors(1, infile, delta=delta, func=rms) data = ui.get_data(1) fit_asymmetric_err(RESULTS_BENCH_RMS, data)
def test_load_ascii_defaultid(filename, delta, make_data_path): """Use the default id""" infile = make_data_path(filename) ui.load_ascii_with_errors(infile, delta=delta) data = ui.get_data() fit_asymmetric_err(RESULTS_BENCH_AVG, data)
def test_gro_ascii(self): ui.load_ascii_with_errors(1, self.gro_fname, delta=False) data = ui.get_data(1) self.fit_asymmetric_err(self._results_bench_avg, data)