def test_validation_geo(): h = '8a28308280fffff' # invalid hex with pytest.raises(H3CellError): h3.h3_to_geo(h) with pytest.raises(H3ResolutionError): h3.geo_to_h3(0, 0, 17) with pytest.raises(H3CellError): h3.h3_to_geo_boundary(h) with pytest.raises(H3CellError): h3.h3_indexes_are_neighbors(h, h)
def test_validation2(): h = '8928308280fffff' with pytest.raises(H3ResolutionError): h3.h3_to_children(h, 17) assert not h3.h3_indexes_are_neighbors(h, h)
def test_edge(): h1 = '8928308280fffff' h2 = '89283082873ffff' assert not h3.h3_indexes_are_neighbors(h1, h1) assert h3.h3_indexes_are_neighbors(h1, h2) e = h3.get_h3_unidirectional_edge(h1, h2) assert e == '12928308280fffff' assert h3.h3_unidirectional_edge_is_valid(e) assert not h3.h3_is_valid(e) assert h3.get_origin_h3_index_from_unidirectional_edge(e) == h1 assert h3.get_destination_h3_index_from_unidirectional_edge(e) == h2 assert h3.get_h3_indexes_from_unidirectional_edge(e) == (h1, h2)
def h3_get_neighbors(region, columns=None): if region.startswith('r_'): region = region[2:] return [x for x in np.unique(columns) if h3.h3_indexes_are_neighbors(region, x[2:])]
def test_h3_indexes_are_neighbors(): assert h3.h3_indexes_are_neighbors('8928308280fffff', '8928308280bffff') assert not h3.h3_indexes_are_neighbors('821c07fffffffff', '8928308280fffff')