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

Use SolaraViz instead of JupyterViz in examples #155

Merged
merged 1 commit into from
Aug 11, 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 examples/boid_flockers/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from boid_flockers.model import BoidFlockers
from mesa.experimental import JupyterViz
from mesa.visualization import SolaraViz


def boid_draw(agent):
Expand All @@ -15,7 +15,7 @@ def boid_draw(agent):
"separation": 2,
}

page = JupyterViz(
page = SolaraViz(
model_class=BoidFlockers,
model_params=model_params,
measures=[],
Expand Down
4 changes: 2 additions & 2 deletions examples/boltzmann_wealth_model_experimental/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from mesa.experimental import JupyterViz
from mesa.visualization import SolaraViz
from model import BoltzmannWealthModel


Expand All @@ -24,7 +24,7 @@ def agent_portrayal(agent):
"height": 10,
}

page = JupyterViz(
page = SolaraViz(
BoltzmannWealthModel,
model_params,
measures=["Gini"],
Expand Down
6 changes: 3 additions & 3 deletions examples/hotelling_law/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from hotelling_law.agents import ConsumerAgent, StoreAgent
from hotelling_law.model import HotellingModel
from matplotlib.figure import Figure
from mesa.experimental import JupyterViz
from mesa.visualization import SolaraViz

model_params = {
"N_stores": {
Expand Down Expand Up @@ -340,8 +340,8 @@ def make_revenue_line_chart(model):
return solara.FigureMatplotlib(fig)


# Instantiate the JupyterViz component with your model
page = JupyterViz(
# Instantiate the SolaraViz component with your model
page = SolaraViz(
model_class=HotellingModel,
model_params=model_params,
measures=[
Expand Down
4 changes: 2 additions & 2 deletions examples/schelling_experimental/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from mesa.visualization.jupyter_viz import JupyterViz, Slider, make_text
from mesa.visualization.solara_viz.py import Slider, SolaraViz, make_text
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line doesn't work.

Copy link
Member Author

@EwoutH EwoutH Aug 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .py should be removed, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, removing .py fixed it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 274a1bc

from model import Schelling


Expand All @@ -21,7 +21,7 @@ def agent_portrayal(agent):
"height": 20,
}

page = JupyterViz(
page = SolaraViz(
Schelling,
model_params,
measures=["happy", make_text(get_happy_agents)],
Expand Down
4 changes: 2 additions & 2 deletions examples/sugarscape_g1mt/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import solara
from matplotlib.figure import Figure
from mesa.experimental import JupyterViz
from mesa.visualization import SolaraViz
from sugarscape_g1mt.model import SugarscapeG1mt
from sugarscape_g1mt.trader_agents import Trader

Expand Down Expand Up @@ -50,7 +50,7 @@ def portray(g):
"height": 50,
}

page = JupyterViz(
page = SolaraViz(
SugarscapeG1mt,
model_params,
measures=["Trader", "Price"],
Expand Down
4 changes: 2 additions & 2 deletions examples/virus_on_network/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import solara
from matplotlib.figure import Figure
from matplotlib.ticker import MaxNLocator
from mesa.experimental import JupyterViz, make_text
from mesa.visualization import SolaraViz, make_text
from virus_on_network.model import State, VirusOnNetwork, number_infected


Expand Down Expand Up @@ -119,7 +119,7 @@ def make_plot(model):
},
}

page = JupyterViz(
page = SolaraViz(
VirusOnNetwork,
model_params,
measures=[
Expand Down