Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
h3.h3_get_resolution(h)
with pytest.raises(H3CellError):
h3.h3_to_parent(h, 9)
with pytest.raises(H3CellError):
h3.h3_distance(h, h)
with pytest.raises(H3CellError):
h3.k_ring(h, 1)
with pytest.raises(H3CellError):
h3.hex_ring(h, 1)
with pytest.raises(H3CellError):
h3.h3_to_children(h, 11)
with pytest.raises(H3CellError):
h3.compact({h})
with pytest.raises(H3CellError):
h3.uncompact({h}, 10)
def test_validation2():
h = '8928308280fffff'
with pytest.raises(H3ResolutionError):
h3.h3_to_children(h, 17)
assert not h3.h3_indexes_are_neighbors(h, h)
# same resolution is set of just cell itself
out = h3.h3_to_children(h, 9)
assert out == {h}
# one below should give children
expected = {
'8a28308280c7fff',
'8a28308280cffff',
'8a28308280d7fff',
'8a28308280dffff',
'8a28308280e7fff',
'8a28308280effff',
'8a28308280f7fff'
}
out = h3.h3_to_children(h, 10)
assert out == expected
# finest resolution cell should return error for children
h = '8f04ccb2c45e225'
with pytest.raises(H3ResolutionError):
h3.h3_to_children(h)
def test_children():
h = '8928308280fffff'
# one above should raise an exception
with pytest.raises(H3ResolutionError):
h3.h3_to_children(h, 8)
# same resolution is set of just cell itself
out = h3.h3_to_children(h, 9)
assert out == {h}
# one below should give children
expected = {
'8a28308280c7fff',
'8a28308280cffff',
'8a28308280d7fff',
'8a28308280dffff',
'8a28308280e7fff',
'8a28308280effff',
'8a28308280f7fff'
}
out = h3.h3_to_children(h, 10)
assert out == expected
# finest resolution cell should return error for children
def test_h3_to_children():
h = '8828308281fffff'
children = h3.h3_to_children(h, 9)
assert len(children) == 7
expected = {
'8a28308280c7fff',
'8a28308280cffff',
'8a28308280d7fff',
'8a28308280dffff',
'8a28308280e7fff',
'8a28308280effff',
'8a28308280f7fff'
}
out = h3.h3_to_children(h, 10)
assert out == expected
# finest resolution cell should return error for children
h = '8f04ccb2c45e225'
with pytest.raises(H3ResolutionError):
h3.h3_to_children(h)
def test_children():
h = '8928308280fffff'
# one above should raise an exception
with pytest.raises(H3ResolutionError):
h3.h3_to_children(h, 8)
# same resolution is set of just cell itself
out = h3.h3_to_children(h, 9)
assert out == {h}
# one below should give children
expected = {
'8a28308280c7fff',
'8a28308280cffff',
'8a28308280d7fff',
'8a28308280dffff',
'8a28308280e7fff',
'8a28308280effff',
'8a28308280f7fff'
}
out = h3.h3_to_children(h, 10)