def test_sky2vec2sky(): """Test that function Region.vec2sky and Region.sky2vec are mutual inverses""" ra, dec = np.radians(np.array((0, -45))) sky = Region.radec2sky(ra, dec) vec = Region.sky2vec(sky) sky2 = Region.vec2sky(vec) if not (np.all(np.array(sky2) - np.array(sky) == 0)): raise AssertionError("sky2vec2sky failed") vec2 = Region.sky2vec(sky2) if not (np.all(np.array(vec) - np.array(vec2) == 0)): raise AssertionError('vec2sky2vec failed')
def test_sky2vec_corners(): """Test that function Region.sky2vec works at some tricky locations""" sky = np.radians([[0, 0], [90, 90], [45, -90]]) answers = np.array([[1, 0, 0], [0, 0, 1], [0, 0, -1]]) vec = Region.sky2vec(sky) if not (np.all(vec - answers < 1e-9)): raise AssertionError('sky2vec corner cases failed')