Skip to content

Commit da2edd3

Browse files
authored
Merge pull request #66 from astronomy-commons/issue/50/plot
Proper handling of ints for writing metadata.
2 parents 517293c + f0ad0d0 commit da2edd3

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

src/hipscat/io/file_io/file_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,4 @@ def write_fits_image(histogram: np.ndarray, map_file_pointer: FilePointer):
127127
value at each index corresponds to the number of objects found at the healpix pixel.
128128
file_pointer: location of file to be written
129129
"""
130-
hp.write_map(map_file_pointer, histogram, overwrite=True)
130+
hp.write_map(map_file_pointer, histogram, overwrite=True, dtype=np.int64)

src/hipscat/io/write_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def write_partition_info(catalog_parameters, destination_pixel_map: dict):
113113
"Npix",
114114
"num_objects",
115115
]
116-
data_frame["Dir"] = int(data_frame["Npix"] / 10_000) * 10_000
116+
data_frame["Dir"] = [int(x / 10_000) * 10_000 for x in data_frame["Npix"]]
117117

118118
# Reorder the columns to match full path, and force to integer types.
119119
data_frame = data_frame[

tests/hipscat/io/test_write_metadata.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,23 @@ def test_write_partition_info(assert_text_file_matches, tmp_path, basic_catalog_
115115
metadata_filename = os.path.join(tmp_path, "small_sky", "partition_info.csv")
116116
assert_text_file_matches(expected_lines, metadata_filename)
117117

118+
expected_lines = [
119+
"Norder,Dir,Npix,num_objects",
120+
"1,0,44,42",
121+
"1,0,45,29",
122+
"1,0,46,42",
123+
"1,0,47,18",
124+
]
125+
pixel_map = {
126+
tuple([1, 44, 42]): [44],
127+
tuple([1, 45, 29]): [45],
128+
tuple([1, 46, 42]): [46],
129+
tuple([1, 47, 18]): [47],
130+
}
131+
io.write_partition_info(basic_catalog_info, pixel_map)
132+
metadata_filename = os.path.join(tmp_path, "small_sky", "partition_info.csv")
133+
assert_text_file_matches(expected_lines, metadata_filename)
134+
118135

119136
def test_write_partition_info_float(
120137
assert_text_file_matches, tmp_path, basic_catalog_info

0 commit comments

Comments
 (0)