17
17
# TODO: Turn this function into a Solara component once the current_step.value
18
18
# dependency is passed to measure()
19
19
def Card (
20
- model , measures , agent_portrayal , space_drawer , current_step , color , layout_type
20
+ model , measures , agent_portrayal , space_drawer , dependencies , color , layout_type
21
21
):
22
22
with rv .Card (
23
23
style_ = f"background-color: { color } ; width: 100%; height: 100%"
@@ -27,11 +27,11 @@ def Card(
27
27
if space_drawer == "default" :
28
28
# draw with the default implementation
29
29
components_matplotlib .SpaceMatplotlib (
30
- model , agent_portrayal , dependencies = [ current_step . value ]
30
+ model , agent_portrayal , dependencies = dependencies
31
31
)
32
32
elif space_drawer == "altair" :
33
33
components_altair .SpaceAltair (
34
- model , agent_portrayal , dependencies = [ current_step . value ]
34
+ model , agent_portrayal , dependencies = dependencies
35
35
)
36
36
elif space_drawer :
37
37
# if specified, draw agent space with an alternate renderer
@@ -44,7 +44,7 @@ def Card(
44
44
measure (model )
45
45
else :
46
46
components_matplotlib .PlotMatplotlib (
47
- model , measure , dependencies = [ current_step . value ]
47
+ model , measure , dependencies = dependencies
48
48
)
49
49
return main
50
50
@@ -115,6 +115,8 @@ def do_reseed():
115
115
reactive_seed .value = model .random .random ()
116
116
117
117
# jupyter
118
+ dependencies = [current_step .value , reactive_seed .value ]
119
+
118
120
def render_in_jupyter ():
119
121
with solara .GridFixed (columns = 2 ):
120
122
UserInputs (user_params , on_change = handle_change_model_params )
@@ -126,11 +128,11 @@ def render_in_jupyter():
126
128
if space_drawer == "default" :
127
129
# draw with the default implementation
128
130
components_matplotlib .SpaceMatplotlib (
129
- model , agent_portrayal , dependencies = [ current_step . value ]
131
+ model , agent_portrayal , dependencies = dependencies
130
132
)
131
133
elif space_drawer == "altair" :
132
134
components_altair .SpaceAltair (
133
- model , agent_portrayal , dependencies = [ current_step . value ]
135
+ model , agent_portrayal , dependencies = dependencies
134
136
)
135
137
elif space_drawer :
136
138
# if specified, draw agent space with an alternate renderer
@@ -144,7 +146,7 @@ def render_in_jupyter():
144
146
measure (model )
145
147
else :
146
148
components_matplotlib .PlotMatplotlib (
147
- model , measure , dependencies = [ current_step . value ]
149
+ model , measure , dependencies = dependencies
148
150
)
149
151
150
152
def render_in_browser ():
@@ -178,7 +180,7 @@ def render_in_browser():
178
180
measures ,
179
181
agent_portrayal ,
180
182
space_drawer ,
181
- current_step ,
183
+ dependencies ,
182
184
color = "white" ,
183
185
layout_type = layout_types [i ],
184
186
)
0 commit comments