Skip to content

Commit

Permalink
Only specify the astropy table columns once. (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
delucchi-cmu authored Jun 14, 2024
1 parent 22cba75 commit de8799c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/hipscat_import/catalog/file_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def read(self, input_file, read_columns=None):
table = Table.read(input_file, memmap=True, **self.kwargs)
if read_columns:
table.keep_columns(read_columns)
if self.column_names:
elif self.column_names:
table.keep_columns(self.column_names)
elif self.skip_column_names:
table.remove_columns(self.skip_column_names)
Expand Down
8 changes: 8 additions & 0 deletions tests/hipscat_import/catalog/test_file_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,17 @@ def test_read_fits_columns(formats_fits):
frame = next(FitsReader(column_names=["id", "ra", "dec"]).read(formats_fits))
assert list(frame.columns) == ["id", "ra", "dec"]

frame = next(FitsReader(column_names=["id", "ra", "dec"]).read(formats_fits, read_columns=["ra", "dec"]))
assert list(frame.columns) == ["ra", "dec"]

frame = next(FitsReader(skip_column_names=["ra_error", "dec_error"]).read(formats_fits))
assert list(frame.columns) == ["id", "ra", "dec", "test_id"]

frame = next(
FitsReader(skip_column_names=["ra_error", "dec_error"]).read(formats_fits, read_columns=["ra", "dec"])
)
assert list(frame.columns) == ["ra", "dec"]


def test_fits_reader_provenance_info(tmp_path, basic_catalog_info):
"""Test that we get some provenance info and it is parseable into JSON."""
Expand Down

0 comments on commit de8799c

Please sign in to comment.