Compact always returns an array of the same length of the input h3Set, however some of the returned elements are not H3Indexes of the compacted set. Doing a list comprehension to get the valid ones yields inconsistent results.
Attached is a set of H3Indexes and a jupyter notebook demonstrating the above.
compact_issue.zip
And a screenshot for readability:
.
My guess is that undef happens to luck onto valid H3Indexes so my suggested fix is to initialize the compactedSet with zeros (an H3Index that is guaranteed to be invalid - see here), and potentially incorporate the list comprehension to return only the valid H3Indexes before returning.
Compact always returns an array of the same length of the input
h3Set
, however some of the returned elements are notH3Index
es of the compacted set. Doing a list comprehension to get the valid ones yields inconsistent results.Attached is a set of
H3Index
es and a jupyter notebook demonstrating the above. compact_issue.zip And a screenshot for readability: .My guess is that
undef
happens to luck onto validH3Index
es so my suggested fix is to initialize thecompactedSet
with zeros (anH3Index
that is guaranteed to be invalid - see here), and potentially incorporate the list comprehension to return only the validH3Index
es before returning.Happy to put up a pull request.