-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Register arrow import/export dispatch to make p2p shuffle work (#295)
- Loading branch information
1 parent
7679bf9
commit fcbddf2
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from packaging.version import Version | ||
|
||
import geopandas | ||
|
||
import dask_geopandas | ||
|
||
import pytest | ||
from geopandas.testing import assert_geodataframe_equal | ||
|
||
distributed = pytest.importorskip("distributed") | ||
|
||
|
||
from distributed import Client, LocalCluster | ||
|
||
|
||
@pytest.mark.skipif( | ||
Version(distributed.__version__) < Version("2024.6.0"), | ||
reason="distributed < 2024.6 has a wrong assertion", | ||
# https://github.com/dask/distributed/pull/8667 | ||
) | ||
@pytest.mark.skipif( | ||
Version(distributed.__version__) < Version("0.13"), | ||
reason="geopandas < 0.13 does not implement sorting geometries", | ||
) | ||
def test_spatial_shuffle(naturalearth_cities): | ||
df_points = geopandas.read_file(naturalearth_cities) | ||
|
||
with LocalCluster(n_workers=1) as cluster: | ||
with Client(cluster): | ||
ddf_points = dask_geopandas.from_geopandas(df_points, npartitions=4) | ||
|
||
ddf_result = ddf_points.spatial_shuffle( | ||
by="hilbert", calculate_partitions=False | ||
) | ||
result = ddf_result.compute() | ||
|
||
expected = df_points.sort_values("geometry").reset_index(drop=True) | ||
assert_geodataframe_equal(result.reset_index(drop=True), expected) |