diff --git a/src/hipscat/pixel_math/healpix_shim.py b/src/hipscat/pixel_math/healpix_shim.py index 2fcf4f54..4b4a34e4 100644 --- a/src/hipscat/pixel_math/healpix_shim.py +++ b/src/hipscat/pixel_math/healpix_shim.py @@ -1,5 +1,5 @@ -import numpy as np import healpy as hp +import numpy as np # pylint: disable=missing-function-docstring @@ -150,6 +150,7 @@ def mindist2avgsize(mindist: np.ndarray) -> np.ndarray: """ return mindist * 1.6 + def avgsize2order(avg_size_arcmin: np.ndarray) -> np.ndarray: """Get the largest order with average healpix size larger than avg_size_arcmin diff --git a/tests/hipscat/pixel_math/test_healpix_shim.py b/tests/hipscat/pixel_math/test_healpix_shim.py index 6e59970d..68f626e8 100644 --- a/tests/hipscat/pixel_math/test_healpix_shim.py +++ b/tests/hipscat/pixel_math/test_healpix_shim.py @@ -1,5 +1,4 @@ import numpy as np -import pytest from numpy.testing import assert_allclose, assert_array_equal from hipscat.pixel_math import healpix_shim as hps @@ -22,3 +21,10 @@ def test_order2avgsize2order(): order = np.arange(20) nside = hps.order2nside(order) assert_array_equal(hps.avgsize2order(hps.nside2resol(nside, arcmin=True)), order) + + +def test_margin2order(): + """Test margin2order for some pre-computed values""" + margin_thr_arcmin = np.array([1 / 60, 10 / 60, 1, 5, 60]) + orders = np.array([17, 13, 11, 8, 5]) + assert_array_equal(hps.margin2order(margin_thr_arcmin), orders)