def assert_expected(h1: H3Index, g1: GeoCoord): assert isinstance(h1, H3Index) assert isinstance(g1, GeoCoord) h2 = g1.to_h3(h1.get_resolution()) assert h1 == h2, "got unexpected GeoCoord.to_h3 output"
import pytest from h3py import GeoCoord, H3Index, hex_ring, set_h3_index lat_rad, lon_rad = 0.659966917655, 2 * 3.14159 - 2.1364398519396 sf = GeoCoord(lat_rad, lon_rad) sfhex = sf.to_h3(9) def test_ring1(): expectedk1 = [ H3Index(0x89283080ddbffff), H3Index(0x89283080c37ffff), H3Index(0x89283080c27ffff), H3Index(0x89283080d53ffff), H3Index(0x89283080dcfffff), H3Index(0x89283080dc3ffff) ] k1 = hex_ring(sfhex, 1) for i in range(6): assert k1[i] != 0, "index is not populated" in_list = 0 for j in range(6): if k1[i] == expectedk1[j]: in_list += 1 assert in_list == 1, "index not found in expected set"