Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename make_geospace_leaflet to make_geospace_component #270

Merged
merged 1 commit into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/tutorials/intro_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down Expand Up @@ -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",
Expand Down
14 changes: 12 additions & 2 deletions mesa_geo/visualization/__init__.py
Original file line number Diff line number Diff line change
@@ -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",
]
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dataclasses
import warnings
from dataclasses import dataclass

import geopandas as gpd
Expand All @@ -18,6 +19,20 @@
view=None,
tiles=xyzservices.providers.OpenStreetMap.Mapnik,
**kwargs,
):
warnings.warn(

Check warning on line 23 in mesa_geo/visualization/components/geospace_component.py

View check run for this annotation

Codecov / codecov/patch

mesa_geo/visualization/components/geospace_component.py#L23

Added line #L23 was not covered by tests
"make_geospace_leaflet is deprecated, use make_geospace_component instead",
DeprecationWarning,
stacklevel=2,
)
return make_geospace_component(agent_portrayal, view, tiles, **kwargs)

Check warning on line 28 in mesa_geo/visualization/components/geospace_component.py

View check run for this annotation

Codecov / codecov/patch

mesa_geo/visualization/components/geospace_component.py#L28

Added line #L28 was not covered by tests


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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
)
Loading