Skip to content

Commit

Permalink
Merge pull request #64 from astronomy-commons/issue/50/plot
Browse files Browse the repository at this point in the history
Update columns of generated partition_info file.
  • Loading branch information
delucchi-cmu authored Mar 28, 2023
2 parents 8f2e17b + d9449d3 commit 65a32a7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
21 changes: 19 additions & 2 deletions src/hipscat/io/write_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,25 @@ def write_partition_info(catalog_parameters, destination_pixel_map: dict):
catalog_parameters.catalog_base_dir
)
data_frame = pd.DataFrame(destination_pixel_map.keys())
data_frame.columns = ["order", "pixel", "num_objects"]
data_frame = data_frame.astype(int)

# Set column names and add a directory column.
data_frame.columns = [
"Norder",
"Npix",
"num_objects",
]
data_frame["Dir"] = int(data_frame["Npix"] / 10_000) * 10_000

# Reorder the columns to match full path, and force to integer types.
data_frame = data_frame[
[
"Norder",
"Dir",
"Npix",
"num_objects",
]
].astype(int)

file_io.write_dataframe_to_csv(data_frame, partition_info_pointer, index=False)


Expand Down
8 changes: 4 additions & 4 deletions tests/hipscat/io/test_write_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def test_write_provenance_info(assert_text_file_matches, tmp_path, basic_catalog
def test_write_partition_info(assert_text_file_matches, tmp_path, basic_catalog_info):
"""Test that we accurately write out the individual partition stats"""
expected_lines = [
"order,pixel,num_objects",
"0,11,131",
"Norder,Dir,Npix,num_objects",
"0,0,11,131",
]
pixel_map = {tuple([0, 11, 131]): [44, 45, 46]}
io.write_partition_info(basic_catalog_info, pixel_map)
Expand All @@ -121,8 +121,8 @@ def test_write_partition_info_float(
"""Test that we accurately write out the individual partition stats
even when the input is floats instead of ints"""
expected_lines = [
"order,pixel,num_objects",
"0,11,131",
"Norder,Dir,Npix,num_objects",
"0,0,11,131",
]
pixel_map = {tuple([0.0, 11.0, 131.0]): [44.0, 45.0, 46.0]}
io.write_partition_info(basic_catalog_info, pixel_map)
Expand Down

0 comments on commit 65a32a7

Please sign in to comment.