def test_bad_init(self): with pytest.raises(HokiFatalError): __, __ = au.AgeWizard( obs_df=fake_cmd_input, model='sdfghj'), 'HokiFatalError should be raised' with pytest.raises(HokiFormatError): __, __ = au.AgeWizard( obs_df='edrftgyhu', model=cmd_file), 'HokiFormatError should be raised'
def test_init_basic(self): assert au.AgeWizard(obs_df=fake_hrd_input, model=hr_file), "Loading HRD file path failed" assert au.AgeWizard( obs_df=fake_hrd_input, model=myhrd), "Loading with hoki.hrdiagrams.HRDiagram failed" assert au.AgeWizard(obs_df=fake_cmd_input, model=mycmd), 'Loading with hoki.cmd.CMD' assert au.AgeWizard(obs_df=fake_cmd_input, model=cmd_file), 'Loading CMD from frile failed'
def test_combine_pdfs_not_you(self): wiz = au.AgeWizard(fake_hrd_input, myhrd) wiz.calculate_sample_pdf(not_you=['star1']) cpdf = wiz.sample_pdf.pdf assert np.sum(np.isclose( [cpdf[0], cpdf[9]], [0.0, 0.7231526323765232])) == 2, "combined pdf is not right"
def test_combine_pdfs(self): wiz = au.AgeWizard(fake_hrd_input, myhrd) wiz.calculate_sample_pdf() assert np.isclose( wiz.sample_pdf.pdf[9], 0.551756734145878), "Something is wrong with the combined_Age PDF"
def test_most_likely_ages(self): wiz = au.AgeWizard(obs_df=fake_hrd_input, model=hr_file) a = wiz.most_likely_ages assert np.sum( np.isclose([a[0], a[1], a[2]], [6.9, 6.9, 6.9])) == 3, "Most likely ages not right"
def test_most_likely_age(self): wiz = au.AgeWizard(obs_df=fake_hrd_input, model=hr_file) assert np.isclose(wiz.most_likely_age[0], 6.9), "Most likely age wrong"
def test_calculate_p_given_age_range(self): wiz = au.AgeWizard(fake_hrd_input, myhrd) probas = wiz.calculate_p_given_age_range([6.7, 6.9]) assert np.sum(np.isclose([probas[0], probas[1], probas[2]], [0.515233714952414, 0.7920611550946726, 0.6542441096583737])) == 3, \ "probability given age range is messed up"