DatalogiForAlle / AgentsPy

Agent-based simulation for education in Python
GNU General Public License v3.0
5 stars 0 forks source link

Make sure all our models still work #87

Closed dybber closed 3 years ago

dybber commented 3 years ago

Make sure all models work with the new interface for making graphs. Currently, many models are broken, and fail with errors like this:

Traceback (most recent call last):
  File "electric.py", line 68, in <module>
    run(modello)
  File "/Users/dpr964/.virtualenvs/AgentsPy/lib/python3.8/site-packages/agents/ui.py", line 560, in run
    app = Application(model)  # noqa: F841
  File "/Users/dpr964/.virtualenvs/AgentsPy/lib/python3.8/site-packages/agents/ui.py", line 398, in __init__
    self.initializeUI()
  File "/Users/dpr964/.virtualenvs/AgentsPy/lib/python3.8/site-packages/agents/ui.py", line 439, in initializeUI
    self.add_plots(self.model.plot_specs, self.plots_box)
  File "/Users/dpr964/.virtualenvs/AgentsPy/lib/python3.8/site-packages/agents/ui.py", line 546, in add_plots
    self.add_line_chart(plot_spec, plots_box)
  File "/Users/dpr964/.virtualenvs/AgentsPy/lib/python3.8/site-packages/agents/ui.py", line 506, in add_line_chart
    chart = QtGraph(line_chart_spec)
  File "/Users/dpr964/.virtualenvs/AgentsPy/lib/python3.8/site-packages/agents/ui.py", line 193, in __init__
    series.setColor(QColor(color[0], color[1], color[2]))
TypeError: 'int' object is not subscriptable
JensKanstrupLarsen commented 3 years ago

This specific one is caused by a change in the ine_chart api function. Since it supports charting multiple lines, instead of

model.line_chart("foo",(42,42,42))

you now need to instead write

model.line_chart(["foo"],[(42,42,42)])