Skip to content

Commit

Permalink
Add support for boolean map with get_map().
Browse files Browse the repository at this point in the history
  • Loading branch information
erykoff committed Apr 26, 2024
1 parent 81e999f commit 9fbe78b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions healsparse/geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ def get_map(self, *, nside_coverage, nside_sparse, dtype, wide_mask_maxbits=None
x = np.zeros(1, dtype=dtype)
if is_integer_value(x[0]):
sentinel = 0
elif dtype == np.bool_:
sentinel = False
else:
sentinel = hpg.UNSEEN

Expand Down
10 changes: 10 additions & 0 deletions tests/test_geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,16 @@ def test_polygon_values(self):
testing.assert_array_equal(smap.valid_pixels, smap2.valid_pixels)
testing.assert_array_equal(smap2.get_values_pix(smap2.valid_pixels), 2.0)

# Test booleans
poly = Polygon(
ra=ra,
dec=dec,
value=True,
)
smap3 = poly.get_map(nside_coverage=32, nside_sparse=nside, dtype=np.bool_)
testing.assert_array_equal(smap.valid_pixels, smap3.valid_pixels)
testing.assert_array_equal(smap3.get_values_pix(smap3.valid_pixels), True)

def test_polygon_nside_render(self):
"""Test using a polygon with a different rendering nside."""
nside = 2**17
Expand Down

0 comments on commit 9fbe78b

Please sign in to comment.