From 77d746fbf636df83dd7a6598db0beed1e94dc075 Mon Sep 17 00:00:00 2001 From: knaaptime Date: Tue, 5 Nov 2024 11:24:50 -0800 Subject: [PATCH 1/8] codecov4 --- .github/workflows/unittests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 5167a386..2c9141c1 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -79,7 +79,7 @@ --cov-report xml - name: codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.xml From a60df09a3c16bfb50aaa48fa41e1125f7fd19769 Mon Sep 17 00:00:00 2001 From: eli knaap Date: Wed, 6 Nov 2024 23:44:10 -0800 Subject: [PATCH 2/8] codecov4 (#220) Co-authored-by: knaaptime --- .github/workflows/unittests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 5167a386..2c9141c1 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -79,7 +79,7 @@ --cov-report xml - name: codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.xml From 46114ef40ddbf7a720596b203d29c77628dd8dd1 Mon Sep 17 00:00:00 2001 From: Martin Fleischmann Date: Tue, 14 Jan 2025 15:21:07 +0100 Subject: [PATCH 3/8] COMPAT: fix compatibility with scipy 1.15 --- tobler/area_weighted/area_interpolate.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tobler/area_weighted/area_interpolate.py b/tobler/area_weighted/area_interpolate.py index 3be6b262..df5e5af5 100644 --- a/tobler/area_weighted/area_interpolate.py +++ b/tobler/area_weighted/area_interpolate.py @@ -12,7 +12,8 @@ from tobler.util.util import _check_crs, _inf_check, _nan_check -__all__ = ['area_interpolate'] +__all__ = ["area_interpolate"] + def _chunk_dfs(geoms_to_chunk, geoms_full, n_jobs): chunk_size = geoms_to_chunk.shape[0] // n_jobs + 1 @@ -250,7 +251,7 @@ def area_interpolate( - "source": build the spatial index on `source_df` - "target": build the spatial index on `target_df` - "auto": attempts to guess the most efficient alternative. - + Currently, this option uses the largest table to build the index, and performs a `bulk_query` on the shorter table. This argument is ignored if n_jobs>1 (or n_jobs=-1). @@ -370,7 +371,7 @@ def area_interpolate( for value in unique: mask = source_df[variable] == value categorical[f"{variable}_{value}"] = np.asarray( - table[mask].sum(axis=0) + table[mask.to_numpy()].sum(axis=0) )[0] categorical = pd.DataFrame(categorical) From 2ce052240499af6b729adba9ed5f43b1007f72c8 Mon Sep 17 00:00:00 2001 From: Martin Fleischmann Date: Sat, 18 Jan 2025 22:41:13 +0100 Subject: [PATCH 4/8] CI: fetch examples ahead of time --- .github/workflows/unittests.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 2c9141c1..a615738e 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -66,6 +66,14 @@ - name: install package run: 'pip install . --no-deps' + - name: Download test files + run: | + python -c ' + import libpysal + + libpysal.examples.fetch_all() + ' + - name: run tests run: | pytest tobler \ From 4eba45f413a3b01582c42695169a7f9e0b408275 Mon Sep 17 00:00:00 2001 From: knaaptime Date: Thu, 23 Jan 2025 10:16:14 -0800 Subject: [PATCH 5/8] get edge length by version; --- tobler/util/util.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tobler/util/util.py b/tobler/util/util.py index 3f88b02d..1735b9da 100644 --- a/tobler/util/util.py +++ b/tobler/util/util.py @@ -35,8 +35,10 @@ def circumradius(resolution): "You can install it with `conda install h3-py` or " "`pip install h3`" ) - - return h3.edge_length(resolution, "m") + h3ver = h3.__version__ + if h3ver < 4: + return h3.edge_length(resolution, "m") + return h3.average_edge_length(resolution, "m") def _check_crs(source_df, target_df): From b31632b22e20bd0599f177a42f93323fd158bec4 Mon Sep 17 00:00:00 2001 From: knaaptime Date: Thu, 23 Jan 2025 10:25:50 -0800 Subject: [PATCH 6/8] convert to number --- tobler/util/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tobler/util/util.py b/tobler/util/util.py index 1735b9da..a0f681e7 100644 --- a/tobler/util/util.py +++ b/tobler/util/util.py @@ -35,7 +35,7 @@ def circumradius(resolution): "You can install it with `conda install h3-py` or " "`pip install h3`" ) - h3ver = h3.__version__ + h3ver = int(h3.__version__[0]) if h3ver < 4: return h3.edge_length(resolution, "m") return h3.average_edge_length(resolution, "m") From d6092e2fdedb0b06b0bc235021221c2d6cbb7db1 Mon Sep 17 00:00:00 2001 From: knaaptime Date: Thu, 23 Jan 2025 10:30:39 -0800 Subject: [PATCH 7/8] add test --- tobler/tests/test_utils.py | 8 ++++++++ tobler/util/util.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tobler/tests/test_utils.py b/tobler/tests/test_utils.py index b5dca26e..6b724196 100644 --- a/tobler/tests/test_utils.py +++ b/tobler/tests/test_utils.py @@ -52,6 +52,14 @@ def test_h3fy_clip(): sac_hex.area.sum(), 13131736346.537422, decimal=0 ) +def test_h3fy_clip_buffer(): + sac1 = load_example("Sacramento1") + sac1 = geopandas.read_file(sac1.get_path("sacramentot2.shp")) + sac_hex = h3fy(sac1, clip=True, buffer=True) + sac_hex = sac_hex.to_crs(sac_hex.estimate_utm_crs()) + assert_almost_equal( + sac_hex.area.sum(), 13749446323.1722, decimal=0 + ) @pytest.mark.skipif(platform.system() == "Windows", reason='Unknown precision error on Windows. See #174 for details') def test_h3_multipoly(): diff --git a/tobler/util/util.py b/tobler/util/util.py index a0f681e7..0c4474f3 100644 --- a/tobler/util/util.py +++ b/tobler/util/util.py @@ -38,7 +38,7 @@ def circumradius(resolution): h3ver = int(h3.__version__[0]) if h3ver < 4: return h3.edge_length(resolution, "m") - return h3.average_edge_length(resolution, "m") + return h3.average_hexagon_edge_length(resolution, "m") def _check_crs(source_df, target_df): From b58302964ea1f04a961fd1b7980bed7487a3e099 Mon Sep 17 00:00:00 2001 From: eli knaap Date: Thu, 23 Jan 2025 11:28:35 -0800 Subject: [PATCH 8/8] Update tobler/util/util.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 💪 Co-authored-by: Martin Fleischmann --- tobler/util/util.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tobler/util/util.py b/tobler/util/util.py index 0c4474f3..88c8add8 100644 --- a/tobler/util/util.py +++ b/tobler/util/util.py @@ -35,8 +35,7 @@ def circumradius(resolution): "You can install it with `conda install h3-py` or " "`pip install h3`" ) - h3ver = int(h3.__version__[0]) - if h3ver < 4: + if Version(h3.__version__) < Version("4.0"): return h3.edge_length(resolution, "m") return h3.average_hexagon_edge_length(resolution, "m")