Skip to content

Commit

Permalink
Merge dev_v4 into master (#250)
Browse files Browse the repository at this point in the history
* WIP: Starting work on v4, The Sequel (#238)

* cimport for h3fake2 doesn't seem to work

* back to where we were

* meh, close to what i was hoping for

* h3fake2 in github actions

* comment out current bindings that consume the h3c v3 library

* don't need the coveragerc file at the moment; clear out c files in /tests

* sdist needs h3fake2

* try CIBW_BEFORE_BUILD to get h3fake2

* need h3fake2 for cibuildwheel tests

* update h3 C library

* comment out most of h3lib.pxd

* calling from v4 c lib works! (tests dont' work yet tho)

* tests shall pass

* starting to move over first few functions

* little steps

* util submodule fully moved over; some hackery with h3fake2 errors

* getting even trickier with h3fake2 errors

* few more simple functions

* geo_to_h3 and h3_to_geo

* grid_distance function

* grid_disk

* parents and kids

* compact/uncompact

* getNumCells

* comment out sdist test temporarily

* commenting out `make_sdist` seems to have turned off the other CI jobs

* no, it was that we're pushing to the dev branch

* keep the sdist job in there, but commented out

* ajfriend/more v4 funcs (#241)

* get_pentagon_indexes and get_res0_indexes

* line

* cell area functions

* get_faces (#248)

* initial pass

* thoughts

* the results of thinking

* this commit is associated with the previous commits

* nogil

* i'm a bill

* remove the typical nonsense

* v4: local ij functions to v4 cython (#240)

* move local ij functions to v4 implementation

* revert some changes and add gridPathCells

* swap implementation

* revert gridPathCells

* ring (#251)

* Uncomment cython example, and exclude sdist from wheels test temporarilty (#252)

* uncomment cython test

* exclude make_sdist temporarily from the wheels tests

* v4: polygonToCells (#254)

* v4: geo boundary, set to multi polygon (#255)

* v4: cell boundary

* v4: h3_set_to_multi_polygon

* v4: convert edge from h3fake2 (#253)

* v4: convert edge from h3fake2

* on error not neighbors

* except *

* check for neighbor error

* Fix sdist build (#239)

* make sure `make_sdist` CI job still broken

* reproduce locally

* update h3lib

* still seems broken

* try sdist on mac and ubuntu

* pyest!

* debugging

* ensurepath

* Disable building docs

* just build sdist once

* colon

Co-authored-by: Isaac Brodsky <isaac@unfolded.ai>

* remove h3fake2 transitional library (#257)

* Remove more sdist files (#259)

* remove scripts/examples/apps

* BUILD_FUZZERS OFF

* ENABLE_FORMAT off

* turn off all the things (and sort options)

* mac attack

* see if there's a build time difference

* back to the future

* New error system (#260)

* starting to play around with new error system

* move enum to h3lib.pxd

* this structure is weird :(

* error system gets its own file

* go back to using H3ErrorCodes

* extern the H3ErrorCodes

* remove H3Index in favor of just H3int

* " to '

* import ordering

* something

* exception hierarchy

* formatting

* errors list

* remove H3ResolutionError

* remove H3EdgeError

* remove H3CellError

* remove H3DistanceError

* H3FailedError

* domain error

* H3UnrecognizedException

* most of em done

* remove H3ValueError

* remove some checks

* ideas ideas

* document what the function raises?

* thoughts

* lint

* one half idea for DRYing (kinda)

* potentially make the E_SUCCESS path faster

* typos

* maple syrup

* cimport H3ErrorCodes as ec

* clean up

* whitespace

* clarify cases

* trying new error idiom

* thanks comment

* notes

* applied idiom a few times now

* alternative idiom?

* handling some more potential errors

* idioms and ideas

* clean

* removing check

* interesting allocation example

* lint

* just trying to beat 2.7 for sport right now

* works?

* bow to lint

* using enum values directly!

* now that's a hierarchy

* remove raise_with_msg

* ij funcs

* lint

* remove some checks

* remove err

* comment

* cleaned up `ring`, and i think i fixed a memory leak bug

* think i fixed another memory leak bug

* another memory leak bug

* memory leaks!

* clean

* removing some comments

* meh

* H3Exception shouldn't be appearing as a concrete object

* renaming some base exceptions

* clean up

* don't have a test for this anyway

* documented

* puttering around

* words

* backing up this nonsense with an airtight argument

* air toight

* todos

* more words

* skepticism

* rewording

* editing

* ordering

* tests on the error codes

* more error code tests

* note

* address some comments

* we raise!

* lint

* comments

* Squash #261: Use new H3MemoryManager system (#268)

* Squash #261: Use new H3MemoryManager system

Co-authored-by: AJ Friend <ajfriend@gmail.com>

* add some error checks

* comments

* comments

* clearer logical flow

* arrays are different from memoryviews!

* little cleaner

* Revert "comments"

This reverts commit 80c3f4d.

* Revert "Revert "comments""

This reverts commit a9d6590.

* Revert "comments"

This reverts commit 24904bd.

* comments

* arrays are different from memoryviews!

* try _copy_to_mv

* i don't get enough opportunities to consider using the word "penultimate"

* ugh, and there i go using it incorrectly...

* hmmm. was this really all it was?

* That's what it was!

This reverts commit 7e72adb.

* clarify branches

* remove simple_mv

* moving around

* clean up

* comments

* comments

* comments

Co-authored-by: Isaac Brodsky <isaac@unfolded.ai>

* remove: from h3 import h3 (#270)

* is_valid_cell (#269)

* Remove alias functions (#271)

* remove alias function hex_range

* note test_k_ring and test_hex_range are the same

* remove test_hex_range

* duplicate tests

* remove test_hex_range2

* same test

* remove test_hex_range_pentagon

* remove alias: k_ring_distances

* tests are the same!

* same test

* combine tests

* remove alias: h3_is_res_class_iii

* lint

* Update most functions to v4.0 names (#272)

* grid_distance

* cell_to_parent

* get_resolution

* is_pentagon

* is_res_class_III

* get_pentagons

* get_res0_cells

* get_base_cell_number

* compact and uncompact

* get_faces

* cell_to_boundary

* cell_to_latlng

* latlng_to_cell

* cell_to_children

* int_to_string and string_to_int

* cell_to_center_child

* moving things around

* is_valid_directed_edge

* grid_path_cells

* moving around

* cells_to_multi_polygon

* are_neighbor_cells

* cell_to_local_ij and local_ij_to_cell

* get_icosahedron_faces

* great_circle_distance

* get_num_cells

* note

* remove hex_range_distances and hex_ranges (easily implementable by user)

* grid_ring

* grid_disk

* moving around

* origin_to_directed_edges

* directed_edge_to_boundary

* cells_to_directed_edge

* directed_edge_to_cells

* todo: directedEdgeToCells

* get_directed_edge_origin

* get_directed_edge_destination

* grouping functions

* more grouping

* _binding to _b

* todos

* average_hexagon_area

* average_edge_length

* average_edge_length and edge_length

* average_hexagon_edge_length

* ordering

* more ordering

* Get the makefile working on Linux (#274)

* bump core lib to 4.0 rc5 (#275)

* bump core lib to 4.0 rc5

* more pythonic names for string<->int conversion functions

* cython hex2int to str_to_int to match the python functions

* better argument names for great_circle_distance

* great_circle_distance comments

* revert great_circle_distance tuple unpacking since it breaks python2. drop python 2 before release

* polygon_to_cells (#276)

* start converting tests over

* converted main tests

* linting

* better null island test

* test_compact_and_uncompact_cells

* convert a few more tests

* add h3.Polygon class

* lint

* migrating some tests

* this shift_circular_list thing makes these tests too hard to understand...

* remove shift_circular_list and convert a few more tests

* last of the tests in test_h3.py converted

* last of the tests converted

* note for polygons_to_cells in the future

* Try out a __repr__ for h3.Polygon

* test_polygon_class.py

* use `cells` instead of `hexes` throughout the library and tests

* docstring for Polygon

* docstrings for functions

* use `res` convention for resolution parameters

Co-authored-by: Isaac Brodsky <isaac@unfolded.ai>
Co-authored-by: David Ellis <isv.damocles@gmail.com>
  • Loading branch information
3 people authored Aug 23, 2022
1 parent f59a1ea commit 6462bf7
Show file tree
Hide file tree
Showing 55 changed files with 2,275 additions and 2,501 deletions.
3 changes: 0 additions & 3 deletions .coveragerc

This file was deleted.

2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ ignore =
E201,
# E241 multiple spaces after ','
E241,
# E731 do not assign a lambda expression, use a def
E731,
4 changes: 2 additions & 2 deletions .github/workflows/coverage-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: coverage-lint

on:
push:
branches: [master]
branches: [master, dev_v4]
pull_request:
branches: [master]
branches: [master, dev_v4]

jobs:
tests:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: tests

on:
push:
branches: [master]
branches: [master, dev_v4]
pull_request:
branches: [master]
branches: [master, dev_v4]

jobs:
tests:
Expand Down
18 changes: 14 additions & 4 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: wheels

on:
push:
branches: [master]
branches: [master, dev_v4]
pull_request:
branches: [master]
branches: [master, dev_v4]
types:
# Opened, synchronize, and reopened are the default types
# We add ready_for_review to additionally trigger when converting from draft to non-draft
Expand All @@ -19,22 +19,32 @@ on:

jobs:
make_sdist:
name: SDist
name: "SDist: ${{ matrix.os }}"
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Python
uses: actions/setup-python@v3.1.2

- name: Make sdist
run: |
python --version
pipx --version
pipx run build --sdist
- name: Install from sdist
run: |
pip install --upgrade pip setuptools wheel
pip install pytest
cp dist/h3-*.tar.gz h3.tar.gz
pip install h3.tar.gz[all]
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ avoid adding features or APIs which do not map onto the

## [3.6.2] - 2020-06-02

- Improve error reporting on `hex2int` (https://github.com/uber/h3-py/pull/127)
- Improve error reporting on `str_to_int` (https://github.com/uber/h3-py/pull/127)
- Build Linux wheels for Python 2.7

## [3.6.1] - 2020-05-29
Expand Down
20 changes: 16 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,22 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_BUILD_TYPE Release)

# Avoid building tooling we won't need for release
set(BUILD_BENCHMARKS OFF CACHE BOOL "" FORCE)
set(BUILD_FILTERS OFF CACHE BOOL "" FORCE)
set(BUILD_GENERATORS OFF CACHE BOOL "" FORCE)
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
# See all options with `cmake -LA` in an `h3/build` directory,
# or at https://h3geo.org/docs/next/core-library/compilation-options/
macro(turn_off option_name)
set(${option_name} OFF CACHE BOOL "" FORCE)
endmacro()
turn_off(BUILD_ALLOC_TESTS)
turn_off(BUILD_BENCHMARKS)
turn_off(BUILD_FILTERS)
turn_off(BUILD_FUZZERS)
turn_off(BUILD_GENERATORS)
turn_off(BUILD_TESTING)
turn_off(ENABLE_COVERAGE)
turn_off(ENABLE_DOCS)
turn_off(ENABLE_FORMAT)
turn_off(ENABLE_LIBFUZZER)
turn_off(ENABLE_LINTING)

# Build the core library as static
set(BUILD_SHARED_LIBS OFF)
Expand Down
3 changes: 0 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ include src/h3lib/README.md
include src/h3lib/VERSION
include src/h3lib/CMakeLists.txt

graft src/h3lib/scripts
graft src/h3lib/examples
graft src/h3lib/cmake
graft src/h3lib/src/h3lib
graft src/h3lib/src/apps
exclude MANIFEST.in
32 changes: 16 additions & 16 deletions docs/api_comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ needs, based on speed and convenience.

```{tip}
Note that the APIs are all 100% compatible, and it is easy to convert
between them with functions like `h3_to_string` (links!) and `string_to_h3`.
between them with functions like `int_to_str` (links!) and `str_to_int`.
For example, one common pattern is to use `h3.api.numpy_int` for any
computationally-heavy work, and convert the output to `str` and `list`/`set`
Expand All @@ -54,11 +54,11 @@ using `list` and `set` for collections.

```python
>>> import h3
>>> h = h3.geo_to_h3(0, 0, 0)
>>> h = h3.latlng_to_cell(0, 0, 0)
>>> h
'8075fffffffffff'

>>> h3.hex_ring(h, 1)
>>> h3.grid_ring(h, 1)
{'8055fffffffffff',
'8059fffffffffff',
'807dfffffffffff',
Expand Down Expand Up @@ -87,11 +87,11 @@ H3 indexes are represented as Python `int`s, using `list` and `set` for collecti

```python
>>> import h3.api.basic_int as h3
>>> h = h3.geo_to_h3(0, 0, 0)
>>> h = h3.latlng_to_cell(0, 0, 0)
>>> h
578536630256664575

>>> h3.hex_ring(h, 1)
>>> h3.grid_ring(h, 1)
{577973680303243263,
578044049047420927,
578677367745019903,
Expand All @@ -110,11 +110,11 @@ no-copy `numpy` arrays instead of Python `list`s and `set`s.

```python
>>> import h3.api.numpy_int as h3
>>> h = h3.geo_to_h3(0, 0, 0)
>>> h = h3.latlng_to_cell(0, 0, 0)
>>> h
578536630256664575

>>> h3.hex_ring(h, 1)
>>> h3.grid_ring(h, 1)
array([578782920861286399, 578044049047420927, 577973680303243263,
578677367745019903, 579169948954263551], dtype=uint64)
```
Expand All @@ -141,11 +141,11 @@ In fact, `h3.api.numpy_int` is essentially just a light wrapper around

```python
>>> import h3.api.memview_int as h3
>>> h = h3.geo_to_h3(0, 0, 0)
>>> h = h3.latlng_to_cell(0, 0, 0)
>>> h
578536630256664575

>>> mv = h3.hex_ring(h, 1)
>>> mv = h3.grid_ring(h, 1)
>>> mv
<MemoryView of 'array' at 0x11188c710>

Expand Down Expand Up @@ -175,8 +175,8 @@ For example, consider the setup:
```python
>>> import h3.api.memview_int as h3
>>> import numpy as np
>>> h = h3.geo_to_h3(0, 0, 0)
>>> mv = h3.hex_ring(h, 1)
>>> h = h3.latlng_to_cell(0, 0, 0)
>>> mv = h3.grid_ring(h, 1)
>>> list(mv)
[578782920861286399,
578044049047420927,
Expand All @@ -200,7 +200,7 @@ Running `a = np.asarray(mv)` **does not create a copy**, so modifying `mv` also
modifies `a`:
```python
>>> mv = h3.hex_ring(h, 1)
>>> mv = h3.grid_ring(h, 1)
>>> a = np.asarray(mv)
>>> mv[0] = 0
>>> a
Expand Down Expand Up @@ -228,15 +228,15 @@ import h3.api.numpy_int


def compute(h3_lib, N=100):
h = h3_lib.geo_to_h3(0, 0, 9)
out = h3_lib.k_ring(h, N)
out = h3_lib.compact(out)
h = h3_lib.latlng_to_cell(0, 0, 9)
out = h3_lib.grid_disk(h, N)
out = h3_lib.compact_cells(out)

return out

def compute_and_convert(h3_lib, N=100):
out = compute(h3_lib, N)
out = [h3.h3_to_string(h) for h in out]
out = [h3.int_to_str(h) for h in out]

return out
```
Expand Down
83 changes: 38 additions & 45 deletions docs/api_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ but we'll try to group functions in a reasonably logical manner.
.. currentmodule:: h3
.. autosummary::
h3_is_valid
h3_is_pentagon
h3_is_res_class_III
h3_is_res_class_iii
h3_unidirectional_edge_is_valid
is_valid_cell
is_pentagon
is_res_class_III
is_valid_directed_edge
versions
```

Expand All @@ -33,16 +32,16 @@ but we'll try to group functions in a reasonably logical manner.
.. currentmodule:: h3
.. autosummary::
geo_to_h3
h3_to_geo
h3_to_string
string_to_h3
get_res0_indexes
get_pentagon_indexes
num_hexagons
h3_get_resolution
compact
uncompact
latlng_to_cell
cell_to_latlng
int_to_str
str_to_int
get_res0_cells
get_pentagons
get_num_cells
get_resolution
compact_cells
uncompact_cells
```

### Geographic coordinates
Expand All @@ -53,17 +52,15 @@ Functions relating H3 objects to geographic (lat/lng) coordinates.
.. currentmodule:: h3
.. autosummary::
point_dist
hex_area
great_circle_distance
average_hexagon_area
cell_area
edge_length
exact_edge_length
h3_to_geo_boundary
get_h3_unidirectional_edge_boundary
polyfill
polyfill_geojson
polyfill_polygon
h3_set_to_multi_polygon
average_hexagon_edge_length
cell_to_boundary
directed_edge_to_boundary
polygon_to_cells
cells_to_polygons
```

### Hierarchical relationships
Expand All @@ -72,9 +69,9 @@ Functions relating H3 objects to geographic (lat/lng) coordinates.
.. currentmodule:: h3
.. autosummary::
h3_to_parent
h3_to_children
h3_to_center_child
cell_to_parent
cell_to_children
cell_to_center_child
```

### Cell grid relationships
Expand All @@ -83,15 +80,11 @@ 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
grid_ring
grid_disk
grid_distance
are_neighbor_cells
grid_path_cells
```

### Edges
Expand All @@ -100,11 +93,11 @@ Functions relating H3 objects to geographic (lat/lng) coordinates.
.. currentmodule:: h3
.. autosummary::
get_h3_unidirectional_edge
get_destination_h3_index_from_unidirectional_edge
get_h3_indexes_from_unidirectional_edge
get_h3_unidirectional_edges_from_hexagon
get_origin_h3_index_from_unidirectional_edge
cells_to_directed_edge
get_directed_edge_destination
directed_edge_to_cells
origin_to_directed_edges
get_directed_edge_origin
```

### IJ-indexing
Expand All @@ -113,10 +106,10 @@ Functions relating H3 objects to geographic (lat/lng) coordinates.
.. currentmodule:: h3
.. autosummary::
h3_get_base_cell
h3_get_faces
experimental_h3_to_local_ij
experimental_local_ij_to_h3
get_base_cell_number
get_icosahedron_faces
cell_to_local_ij
local_ij_to_cell
```


Expand Down
Loading

0 comments on commit 6462bf7

Please sign in to comment.