diff --git a/docs/tutorials/intro_tutorial.ipynb b/docs/tutorials/intro_tutorial.ipynb index 128adb50..39d04b7e 100644 --- a/docs/tutorials/intro_tutorial.ipynb +++ b/docs/tutorials/intro_tutorial.ipynb @@ -99,7 +99,7 @@ "import mesa\n", "from mesa.visualization import SolaraViz, make_plot_component\n", "import mesa_geo as mg\n", - "from mesa_geo.visualization import make_geospace_leaflet" + "from mesa_geo.visualization import make_geospace_component" ] }, { @@ -1060,7 +1060,7 @@ " name=\"GeoSIR\",\n", " model_params=model_params,\n", " components=[\n", - " make_geospace_leaflet(SIR_draw, zoom=12, scroll_wheel_zoom=False),\n", + " make_geospace_component(SIR_draw, zoom=12, scroll_wheel_zoom=False),\n", " make_plot_component([\"infected\", \"susceptible\", \"recovered\", \"dead\"]),\n", " make_plot_component([\"safe\", \"hotspot\"]),\n", " ],\n", diff --git a/mesa_geo/visualization/__init__.py b/mesa_geo/visualization/__init__.py index 25a6ebd0..0da04b8b 100644 --- a/mesa_geo/visualization/__init__.py +++ b/mesa_geo/visualization/__init__.py @@ -1,6 +1,16 @@ # Import specific classes or functions from the modules -from .components.geospace_leaflet import MapModule, make_geospace_leaflet +from .components.geospace_component import ( + MapModule, + make_geospace_component, + make_geospace_leaflet, +) from .geojupyter_viz import GeoJupyterViz from .leaflet_viz import LeafletViz -__all__ = ["GeoJupyterViz", "LeafletViz", "MapModule", "make_geospace_leaflet"] +__all__ = [ + "GeoJupyterViz", + "LeafletViz", + "MapModule", + "make_geospace_component", + "make_geospace_leaflet", +] diff --git a/mesa_geo/visualization/components/geospace_leaflet.py b/mesa_geo/visualization/components/geospace_component.py similarity index 96% rename from mesa_geo/visualization/components/geospace_leaflet.py rename to mesa_geo/visualization/components/geospace_component.py index 7e279baf..dc1ddab8 100644 --- a/mesa_geo/visualization/components/geospace_leaflet.py +++ b/mesa_geo/visualization/components/geospace_component.py @@ -1,4 +1,5 @@ import dataclasses +import warnings from dataclasses import dataclass import geopandas as gpd @@ -18,6 +19,20 @@ def make_geospace_leaflet( view=None, tiles=xyzservices.providers.OpenStreetMap.Mapnik, **kwargs, +): + warnings.warn( + "make_geospace_leaflet is deprecated, use make_geospace_component instead", + DeprecationWarning, + stacklevel=2, + ) + return make_geospace_component(agent_portrayal, view, tiles, **kwargs) + + +def make_geospace_component( + agent_portrayal, + view=None, + tiles=xyzservices.providers.OpenStreetMap.Mapnik, + **kwargs, ): def MakeSpaceMatplotlib(model): return GeoSpaceLeaflet(model, agent_portrayal, view, tiles, **kwargs) diff --git a/tests/test_geospace_leaflet.py b/tests/test_geospace_component.py similarity index 65% rename from tests/test_geospace_leaflet.py rename to tests/test_geospace_component.py index b7aca37b..4d0e545d 100644 --- a/tests/test_geospace_leaflet.py +++ b/tests/test_geospace_component.py @@ -4,12 +4,12 @@ from mesa.visualization.solara_viz import SolaraViz import mesa_geo.visualization as mgv -from mesa_geo.visualization import make_geospace_leaflet +from mesa_geo.visualization import make_geospace_component -def test_geospace_leaflet(mocker): - mock_geospace_leaflet = mocker.spy( - mgv.components.geospace_leaflet, "GeoSpaceLeaflet" +def test_geospace_component(mocker): + mock_geospace_component = mocker.spy( + mgv.components.geospace_component, "GeoSpaceLeaflet" ) model = mesa.Model() @@ -22,8 +22,10 @@ def test_geospace_leaflet(mocker): } # initialize with space drawer unspecified (use default) # component must be rendered for code to run - solara.render(SolaraViz(model, components=[make_geospace_leaflet(agent_portrayal)])) + solara.render( + SolaraViz(model, components=[make_geospace_component(agent_portrayal)]) + ) # should call default method with class instance and agent portrayal - mock_geospace_leaflet.assert_called_with( + mock_geospace_component.assert_called_with( model, agent_portrayal, None, xyzservices.providers.OpenStreetMap.Mapnik )