def test_converts_list_of_strings_to_dict_if_comments_in_table_meta(self): tbl = ioascii.read("""# key1 : val 1 # key2 : extra long entry col1 col2 0 1 """) dic = convert_table_comments_to_dict(tbl) assert dic["key1"] == "val 1" assert len(dic) == 2
def input_tables(): filenames = ["test_table.fits", "test_table.tbl"] filenames = [os.path.join(MOCK_DIR, fname) for fname in filenames] tbls = [] tbls += [Table.read(filenames[0])] tbls += [Table.read(filenames[1], format="ascii.basic")] tbls[1].meta.update(convert_table_comments_to_dict(tbls[1])) return tbls
def test_returns_input_if_conversion_doesnt_work(self): tbl_str = """ # key1 : val 1 # # key2 col1 col2 0 1 """ tbl = ioascii.read(tbl_str) dic = convert_table_comments_to_dict(tbl) assert dic == tbl.meta["comments"]
def input_spectra(): filenames = ["test_spectrum_photlam.dat", "test_spectrum_Flam.dat"] filenames = [os.path.join(MOCK_DIR, fname) for fname in filenames] tbls = [ioascii.read(fname) for fname in filenames] specs = [] for tbl in tbls: tbl.meta.update(convert_table_comments_to_dict(tbl)) wave = tbl["wavelength"] * u.Unit(tbl.meta["wavelength_unit"]) flux = tbl["flux"] * u.Unit(tbl.meta["flux_unit"]) specs += [SourceSpectrum(Empirical1D, points=wave, lookup_table=flux)] return specs
def test_returns_empty_dict_if_comments_not_in_table_meta(self): tbl = ioascii.read("""col1 col2 0 1 """) dic = convert_table_comments_to_dict(tbl) assert dic == {}