Exemple #1
0
 def test_covar_wrong_stat(self):
     ui.covar()
     fail = False
     wrong_stats = set(ui.list_stats()) - self.right_stats
     for stat in wrong_stats:
         ui.set_stat(stat)
         try:
             ui.get_draws()
         except ValueError as ve:
             self.assertEqual(self.wrong_stat_msg.format(stat), str(ve))
             continue
         fail = True
         break
     if fail:
         self.fail(self.fail_msg)
Exemple #2
0
 def test_covar_wrong_stat(self):
     ui.covar()
     fail = False
     wrong_stats = set(ui.list_stats()) - self.right_stats
     for stat in wrong_stats:
         ui.set_stat(stat)
         try:
             ui.get_draws()
         except ValueError as ve:
             self.assertEqual(self.wrong_stat_msg.format(stat), ve.message)
             continue
         fail = True
         break
     if fail:
         self.fail(self.fail_msg)
Exemple #3
0
WRONG_STAT_MSG = "Fit statistic must be cash, cstat or wstat, not {}"
WSTAT_ERR_MSG = "No background data has been supplied. Use cstat"
NO_COVAR_MSG = "covariance has not been performed"
RIGHT_STATS = {'cash', 'cstat', 'wstat'}


@pytest.fixture
def setup_covar(make_data_path):

    print("A")
    ui.load_data(make_data_path('sim.poisson.1.dat'))
    ui.set_model(PowLaw1D("p1"))


@requires_data
@pytest.mark.parametrize('stat', sorted(set(ui.list_stats()) - RIGHT_STATS))
def test_covar_wrong_stat(stat, clean_ui, setup_covar):
    "Test an exception is thrown is the proper stat is not set"

    ui.covar()
    ui.set_stat(stat)
    with pytest.raises(ValueError) as exc:
        ui.get_draws()

    assert WRONG_STAT_MSG.format(stat) == str(exc.value)


@requires_data
def test_covar_wstat_no_background(clean_ui, setup_covar):
    "Test an exception is thrown when wstat is used without background"