Skip to content

Commit

Permalink
remove usage of geopandas.datasets (#194)
Browse files Browse the repository at this point in the history
* remove usage of geopandas.datasets

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix docstring

* proper fix

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
martinfleis and pre-commit-ci[bot] authored Sep 6, 2023
1 parent 2788475 commit 40854b8
Show file tree
Hide file tree
Showing 3 changed files with 833 additions and 324 deletions.
6 changes: 4 additions & 2 deletions mapclassify/greedy.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,10 @@ def greedy(
>>> from mapclassify import greedy
>>> import geopandas
>>> world = geopandas.read_file(geopandas.datasets.get_path("naturalearth_lowres"))
>>> africa = world.loc[world.continent == "Africa"].copy()
>>> world = geopandas.read_file(
... "https://naciscdn.org/naturalearth/110m/cultural/ne_110m_admin_0_countries.zip"
... )
>>> africa = world.loc[world.CONTINENT == "Africa"].copy()
>>> africa = africa.to_crs("ESRI:102022").reset_index(drop=True)
Default:
Expand Down
6 changes: 4 additions & 2 deletions mapclassify/tests/test_greedy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

PY39 = sys.version_info.major == 3 and sys.version_info.minor == 9

world = geopandas.read_file(geopandas.datasets.get_path("naturalearth_lowres"))
world = geopandas.read_file(
"https://naciscdn.org/naturalearth/110m/cultural/ne_110m_admin_0_countries.zip"
)
sw = libpysal.weights.Queen.from_dataframe(
world, ids=world.index.to_list(), silence_warnings=True
)
Expand Down Expand Up @@ -36,7 +38,7 @@ def test_sw(self):
assert colors.value_counts().to_list() == [36, 36, 35, 35, 35]

def test_min_distance(self):
europe = world.loc[world.continent == "Europe"].to_crs(epsg=3035)
europe = world.loc[world.CONTINENT == "Europe"].to_crs(epsg=3035)
colors = greedy(europe, min_distance=500000)
assert len(colors) == len(europe)
assert set(colors) == set(range(13))
Expand Down
1,145 changes: 825 additions & 320 deletions notebooks/05_Greedy_coloring.ipynb

Large diffs are not rendered by default.

0 comments on commit 40854b8

Please sign in to comment.