diff --git a/healsparse/geom.py b/healsparse/geom.py index 93ef221..d22424f 100644 --- a/healsparse/geom.py +++ b/healsparse/geom.py @@ -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 diff --git a/tests/test_geom.py b/tests/test_geom.py index 8242520..de1018a 100644 --- a/tests/test_geom.py +++ b/tests/test_geom.py @@ -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