def test_to_local_ij_error(): h = h3.geo_to_h3(0, 0, 0) # error if we cross a face nb = h3.hex_ring(h, k=2) with pytest.raises(H3ValueError): [h3.experimental_h3_to_local_ij(h, p) for p in nb] # should be fine if we do not cross a face nb = h3.hex_ring(h, k=1) out = {h3.experimental_h3_to_local_ij(h, p) for p in nb} expected = {(-1, 0), (0, -1), (0, 1), (1, 0), (1, 1)} assert out == expected
def test_from_local_ij_error(): h = h3.geo_to_h3(0, 0, 0) baddies = [(1, -1), (-1, 1), (-1, -1)] for i, j in baddies: with pytest.raises(H3ValueError): h3.experimental_local_ij_to_h3(h, i, j) # inverting output should give good data nb = h3.hex_ring(h, k=1) goodies = {h3.experimental_h3_to_local_ij(h, p) for p in nb} out = {h3.experimental_local_ij_to_h3(h, i, j) for i, j in goodies} assert out == nb
def test_to_local_ij_self(): h = h3.geo_to_h3(0, 0, 9) out = h3.experimental_h3_to_local_ij(h, h) assert out == (-858, -2766)