Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove alias functions #271

Merged
merged 13 commits into from
Aug 13, 2022
3 changes: 0 additions & 3 deletions docs/api_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ but we'll try to group functions in a reasonably logical manner.
is_valid_cell
h3_is_pentagon
h3_is_res_class_III
h3_is_res_class_iii
h3_unidirectional_edge_is_valid
versions
```
Expand Down Expand Up @@ -83,12 +82,10 @@ Functions relating H3 objects to geographic (lat/lng) coordinates.
.. currentmodule:: h3

.. autosummary::
hex_range
hex_range_distances
hex_ranges
hex_ring
k_ring
k_ring_distances
h3_distance
h3_indexes_are_neighbors
h3_line
Expand Down
21 changes: 0 additions & 21 deletions src/h3/api/_api_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,19 +312,6 @@ def k_ring(self, h, k=1):

return self._out_unordered(mv)

def hex_range(self, h, k=1):
"""
Alias for `k_ring`.
"Filled-in" disk.

Notes
-----
This name differs from the C API.
"""
mv = _cy.disk(self._in_scalar(h), k)

return self._out_unordered(mv)

def hex_ring(self, h, k=1):
"""
Return unordered set of cells with H3 distance ``== k`` from ``h``.
Expand Down Expand Up @@ -382,10 +369,6 @@ def hex_ranges(self, hexes, K):

return out

def k_ring_distances(self, h, K):
"""Alias for `hex_range_distances`."""
return self.hex_range_distances(h, K)

def h3_to_children(self, h, res=None):
"""
Children of a hexagon.
Expand Down Expand Up @@ -743,10 +726,6 @@ def h3_is_res_class_III(self, h):
"""
return _cy.is_res_class_iii(self._in_scalar(h))

def h3_is_res_class_iii(self, h):
"""Alias for `h3_is_res_class_III`."""
return self.h3_is_res_class_III(h)

def get_pentagon_indexes(self, resolution):
"""
Return all pentagons at a given resolution.
Expand Down
3 changes: 0 additions & 3 deletions src/h3/api/basic_int/_public_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
h3_indexes_are_neighbors = _binding.h3_indexes_are_neighbors
h3_is_pentagon = _binding.h3_is_pentagon
h3_is_res_class_III = _binding.h3_is_res_class_III
h3_is_res_class_iii = _binding.h3_is_res_class_iii
is_valid_cell = _binding.is_valid_cell
h3_line = _binding.h3_line
h3_set_to_multi_polygon = _binding.h3_set_to_multi_polygon
Expand All @@ -50,12 +49,10 @@
h3_to_string = _binding.h3_to_string
h3_unidirectional_edge_is_valid = _binding.h3_unidirectional_edge_is_valid
hex_area = _binding.hex_area
hex_range = _binding.hex_range
hex_range_distances = _binding.hex_range_distances
hex_ranges = _binding.hex_ranges
hex_ring = _binding.hex_ring
k_ring = _binding.k_ring
k_ring_distances = _binding.k_ring_distances
num_hexagons = _binding.num_hexagons
point_dist = _binding.point_dist
polyfill = _binding.polyfill
Expand Down
125 changes: 19 additions & 106 deletions tests/test_h3.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,31 +154,6 @@ def test_k_ring_pentagon():
assert out == expected


def test_k_ring_distances():
h = '8928308280fffff'
out = h3.k_ring_distances(h, 1)

assert [len(x) for x in out] == [1, 6]

expected = [
{h},
{
'8928308280bffff',
'89283082807ffff',
'89283082877ffff',
'89283082803ffff',
'89283082873ffff',
'8928308283bffff',
}
]

assert out == expected

out = h3.k_ring_distances('870800003ffffff', 2)

assert [len(x) for x in out] == [1, 6, 11]


def test_polyfill():
geo = {
'type': 'Polygon',
Expand Down Expand Up @@ -656,69 +631,21 @@ def test_h3_to_children():
assert len(children) == 7


def test_hex_range():
h = '8928308280fffff'
out = h3.hex_range(h, 1)
assert len(out) == 1 + 6

expected = {
'8928308280bffff',
'89283082807ffff',
h,
'89283082877ffff',
'89283082803ffff',
'89283082873ffff',
'8928308283bffff',
}

assert out == expected


def test_hex_range2():
h = '8928308280fffff'
out = h3.hex_range(h, 2)

assert len(out) == 1 + 6 + 12

expected = {
'89283082813ffff',
'89283082817ffff',
'8928308281bffff',
'89283082863ffff',
'89283082823ffff',
'89283082873ffff',
'89283082877ffff',
'8928308287bffff',
'89283082833ffff',
'8928308282bffff',
'8928308283bffff',
'89283082857ffff',
'892830828abffff',
'89283082847ffff',
'89283082867ffff',
'89283082803ffff',
h,
'89283082807ffff',
'8928308280bffff',
}

assert out == expected


def test_hex_range_pentagon():
h = '821c07fffffffff' # a pentagon
def test_hex_range_distances_pentagon():

# should consist of `h` and it's 5 neighbors
out = h3.hex_range(h, 1)
h = '821c07fffffffff'
out = h3.hex_range_distances(h, 1)

expected = {
h,
'821c17fffffffff',
'821c1ffffffffff',
'821c27fffffffff',
'821c2ffffffffff',
'821c37fffffffff',
}
expected = [
{h},
{
'821c17fffffffff',
'821c1ffffffffff',
'821c27fffffffff',
'821c2ffffffffff',
'821c37fffffffff',
}
]

assert out == expected

Expand All @@ -729,6 +656,8 @@ def test_hex_range_distances():
# should consist of `h` and it's 5 neighbors
out = h3.hex_range_distances(h, 1)

assert [len(x) for x in out] == [1, 6]

expected = [
{h},
{
Expand All @@ -743,24 +672,9 @@ def test_hex_range_distances():

assert out == expected

out = h3.hex_range_distances('870800003ffffff', 2)

def test_hex_range_distances_pentagon():

h = '821c07fffffffff'
out = h3.hex_range_distances(h, 1)

expected = [
{h},
{
'821c17fffffffff',
'821c1ffffffffff',
'821c27fffffffff',
'821c2ffffffffff',
'821c37fffffffff',
}
]

assert out == expected
assert [len(x) for x in out] == [1, 6, 11]


def test_hex_ranges():
Expand Down Expand Up @@ -856,10 +770,9 @@ def test_h3_get_base_cell():
assert h3.h3_get_base_cell('8928308280fffff') == 20


def test_h3_is_res_class_iiiIII():
assert h3.h3_is_res_class_iii('8928308280fffff')
assert not h3.h3_is_res_class_iii('8828308280fffff')
def test_h3_is_res_class_III():
assert h3.h3_is_res_class_III('8928308280fffff')
assert not h3.h3_is_res_class_III('8828308280fffff')


def test_h3_is_pentagon():
Expand Down