From 9c17c030fd900965038bc962d540f3f797332b52 Mon Sep 17 00:00:00 2001 From: Martin Fleischmann Date: Fri, 3 Nov 2023 23:04:53 +0100 Subject: [PATCH] pass kwargs to explore --- libpysal/graph/_plotting.py | 11 ++++++++++- libpysal/graph/base.py | 5 +++++ libpysal/graph/tests/test_plotting.py | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/libpysal/graph/_plotting.py b/libpysal/graph/_plotting.py index 600fa8c6e..dd77f6904 100644 --- a/libpysal/graph/_plotting.py +++ b/libpysal/graph/_plotting.py @@ -149,6 +149,7 @@ def _explore_graph( node_kws=None, focal_kws=None, m=None, + **kwargs, ): """Plot graph as an interactive Folium Map @@ -177,6 +178,10 @@ def _explore_graph( passing a subset of nodes with the `focal` argument m : Folilum.Map, optional folium map objecto to plot on top of, by default None + **kwargs : dict, optional + additional keyword arguments are passed directly to geopandas.explore, when + ``m=None`` by default None + Returns ------- @@ -230,7 +235,11 @@ def _explore_graph( ["focal", "neighbor", "weight", "geometry"] ] - m = edges.explore(m=m, **edge_kws) if m is not None else edges.explore(**edge_kws) + m = ( + edges.explore(m=m, **edge_kws) + if m is not None + else edges.explore(**edge_kws, **kwargs) + ) if nodes is True: if focal is not None: diff --git a/libpysal/graph/base.py b/libpysal/graph/base.py index f991720ce..b576365b3 100644 --- a/libpysal/graph/base.py +++ b/libpysal/graph/base.py @@ -1288,6 +1288,7 @@ def explore( node_kws=None, focal_kws=None, m=None, + **kwargs, ): """Plot graph as an interactive Folium Map @@ -1314,6 +1315,9 @@ def explore( passing a subset of nodes with the `focal` argument m : Folilum.Map, optional folium map objecto to plot on top of, by default None + **kwargs : dict, optional + additional keyword arguments are passed directly to geopandas.explore, when + ``m=None`` by default None Returns ------- @@ -1330,6 +1334,7 @@ def explore( node_kws=node_kws, focal_kws=focal_kws, m=m, + **kwargs, ) diff --git a/libpysal/graph/tests/test_plotting.py b/libpysal/graph/tests/test_plotting.py index 3a2f67e08..a6c15e8fe 100644 --- a/libpysal/graph/tests/test_plotting.py +++ b/libpysal/graph/tests/test_plotting.py @@ -368,3 +368,9 @@ def test_m(self): assert s.count("LineString") == 6 # geoms assert s.count("Polygon") == 5 + + def test_explore_kwargs(self): + m = self.G_str.explore(self.nybb_str, tiles="OpenStreetMap HOT") + s = fetch_map_string(m) + + assert "tile.openstreetmap.fr/hot" in s