def test_ci_report_with_offset(confidence_interval): """Verify output of CI report when using with_offset.""" report_split = ci_report(confidence_interval, with_offset=True).split('\n') # default amp_values = [abs(float(val)) for val in report_split[1].split()[2:]] assert np.all(np.less(np.delete(amp_values, 3), 0.2)) report_split = ci_report(confidence_interval, with_offset=False).split('\n') amp_values = [float(val) for val in report_split[1].split()[2:]] assert np.all(np.greater(amp_values, 13))
def test_ci_report(confidence_interval): """Verify that the CI report is created when using ci_report.""" report = ci_report(confidence_interval) assert len(report) > 250 for par in confidence_interval.keys(): assert par in report for interval in ['99.73', '95.45', '68.27', '_BEST_']: assert interval in report
def test_ci_report(): """test confidence interval report""" def residual(pars, x, data=None): argu = (x * pars['decay'])**2 shift = pars['shift'] if abs(shift) > np.pi / 2: shift = shift - np.sign(shift) * np.pi model = pars['amp'] * np.sin(shift + x / pars['period']) * np.exp(-argu) if data is None: return model return model - data p_true = Parameters() p_true.add('amp', value=14.0) p_true.add('period', value=5.33) p_true.add('shift', value=0.123) p_true.add('decay', value=0.010) n = 2500 xmin = 0. xmax = 250.0 x = np.linspace(xmin, xmax, n) data = residual(p_true, x) + np.random.normal(scale=0.7215, size=n) fit_params = Parameters() fit_params.add('amp', value=13.0) fit_params.add('period', value=2) fit_params.add('shift', value=0.0) fit_params.add('decay', value=0.02) mini = Minimizer(residual, fit_params, fcn_args=(x, ), fcn_kws={'data': data}) out = mini.leastsq() report = fit_report(out) assert (len(report) > 500) ci, tr = conf_interval(mini, out, trace=True) report = ci_report(ci) assert (len(report) > 250)
def test_ci_report(): """test confidence interval report""" def residual(pars, x, data=None): argu = (x*pars['decay'])**2 shift = pars['shift'] if abs(shift) > np.pi/2: shift = shift - np.sign(shift)*np.pi model = pars['amp']*np.sin(shift + x/pars['period']) * np.exp(-argu) if data is None: return model return model - data p_true = Parameters() p_true.add('amp', value=14.0) p_true.add('period', value=5.33) p_true.add('shift', value=0.123) p_true.add('decay', value=0.010) n = 2500 xmin = 0. xmax = 250.0 x = np.linspace(xmin, xmax, n) data = residual(p_true, x) + np.random.normal(scale=0.7215, size=n) fit_params = Parameters() fit_params.add('amp', value=13.0) fit_params.add('period', value=2) fit_params.add('shift', value=0.0) fit_params.add('decay', value=0.02) mini = Minimizer(residual, fit_params, fcn_args=(x,), fcn_kws={'data': data}) out = mini.leastsq() report = fit_report(out) assert(len(report) > 500) ci, tr = conf_interval(mini, out, trace=True) report = ci_report(ci) assert(len(report) > 250)
def test_ci_report_with_ndigits(confidence_interval, ndigits): """Verify output of CI report when specifying ndigits.""" report_split = ci_report(confidence_interval, ndigits=ndigits).split('\n') period_values = list(report_split[2].split()[2:]) length = [len(val.split('.')[-1]) for val in period_values] assert np.all(np.equal(length, ndigits))
def confidence_report(conf_vals, **kws): """return a formatted report of confidence intervals calcualted by confidence_intervals """ return ci_report(conf_vals)
def confidence_report(conf_vals, **kws): """return a formatted report of confidence intervals calcualted by confidence_intervals""" return ci_report(conf_vals)