Skip to content

Commit

Permalink
Being experimental, try contain instead of containment in params
Browse files Browse the repository at this point in the history
  • Loading branch information
ajfriend committed Dec 31, 2024
1 parent 022de27 commit 49dbf59
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/h3/api/basic_int/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,12 +525,12 @@ def polygon_to_cells(h3shape, res):
return h3shape_to_cells(h3shape, res)


def h3shape_to_cells_experimental(h3shape, res, containment='center'):
def h3shape_to_cells_experimental(h3shape, res, contain='center'):
"""
Experimental function similar to ``h3shape_to_cells``, but with support for
multiple cell containment modes.
Using ``containment='center'`` should give identical behavior as
Using ``contain='center'`` should give identical behavior as
``h3shape_to_cells``.
Note that this function is **experimental** and has no API stability gaurantees
Expand All @@ -542,7 +542,7 @@ def h3shape_to_cells_experimental(h3shape, res, containment='center'):
h3shape : ``H3Shape``
res : int
Resolution of the output cells
containment : {'center', 'full', 'overlap', 'bbox_overlap'}
contain : {'center', 'full', 'overlap', 'bbox_overlap'}
Specifies the containment condition.
- 'center': Cell center is contained in shape
- 'full': Cell is fully contained in shape
Expand Down Expand Up @@ -574,14 +574,14 @@ def h3shape_to_cells_experimental(h3shape, res, containment='center'):
There is currently no guaranteed order of the output cells.
"""

containment_modes = {
contain_modes = {
'center': 0,
'full': 1,
'overlap': 2,
'bbox_overlap': 3,
}

flag = containment_modes[containment]
flag = contain_modes[contain]

# todo: not sure if i want this dispatch logic here. maybe in the objects?
if isinstance(h3shape, LatLngPoly):
Expand Down
16 changes: 8 additions & 8 deletions tests/test_lib/polyfill/test_h3.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_polygon_to_cells():
def test_h3shape_to_cells_experimental():
poly = h3.LatLngPoly(sf_7x7)

out = h3.h3shape_to_cells_experimental(poly, res=9, containment='center')
out = h3.h3shape_to_cells_experimental(poly, res=9, contain='center')

assert len(out) == 1253
assert '89283080527ffff' in out
Expand All @@ -130,7 +130,7 @@ def test_h3shape_to_cells_experimental():
def test_h3shape_to_cells_experimental_full():
poly = h3.LatLngPoly(sf_7x7)

out = h3.h3shape_to_cells_experimental(poly, res=9, containment='full')
out = h3.h3shape_to_cells_experimental(poly, res=9, contain='full')

assert len(out) == 1175
assert '89283082a1bffff' in out
Expand All @@ -141,7 +141,7 @@ def test_h3shape_to_cells_experimental_full():
def test_h3shape_to_cells_experimental_overlapping():
poly = h3.LatLngPoly(sf_7x7)

out = h3.h3shape_to_cells_experimental(poly, res=9, containment='overlap')
out = h3.h3shape_to_cells_experimental(poly, res=9, contain='overlap')

assert len(out) == 1334
assert '89283080527ffff' in out
Expand All @@ -150,7 +150,7 @@ def test_h3shape_to_cells_experimental_overlapping():

def test_h3shape_to_cells_experimental_overlapping_bbox():
poly = h3.LatLngPoly(sf_7x7)
out = h3.h3shape_to_cells_experimental(poly, res=9, containment='bbox_overlap')
out = h3.h3shape_to_cells_experimental(poly, res=9, contain='bbox_overlap')

assert len(out) == 1416
assert '89283080527ffff' in out
Expand All @@ -163,7 +163,7 @@ def test_h3shape_to_cells_experimental_invalid_mode():
h3.h3shape_to_cells_experimental(
poly,
res = 9,
containment = 'containment_overlapping_bbox_abc',
contain = 'contain_overlapping_bbox_abc',
)


Expand All @@ -176,7 +176,7 @@ def test_poly_to_cells_experimental_mpoly():
assert (
set(h3.h3shape_to_cells_experimental(mpoly, res=9))
==
set(h3.h3shape_to_cells_experimental(mpoly, res=9, containment='center'))
set(h3.h3shape_to_cells_experimental(mpoly, res=9, contain='center'))
)

assert (
Expand All @@ -185,14 +185,14 @@ def test_poly_to_cells_experimental_mpoly():
set(h3.h3shape_to_cells_experimental(
mpoly,
res = 9,
containment = 'overlap'
contain = 'overlap'
))
)

assert 120 == len(h3.h3shape_to_cells_experimental(
mpoly,
res = 9,
containment = 'overlap'
contain = 'overlap'
))


Expand Down

0 comments on commit 49dbf59

Please sign in to comment.