Fix forest_fire notebook for Mesa 4 compatibility
Fixes forest_fire notebook to work with Mesa 4, replacing removed and deprecated APIs.
Changes:
- Replace deprecated imports (BatchRunner, mesa.datacollection)
with
import mesaandimport pandas as pd - Replace deprecated
fire.run_model()withwhile fire.running: fire.step() - Fix
fire.dc→fire.datacollector - Replace removed
BatchRunnerwithmesa.batch_run() - Fix DataFrame column access:
df.BurnedOut→df["Burned Out"]
Fixes #421 Related: #3132, #3270
Hey, good work on this! The migration approach is solid and you've got the right idea. Just a couple of things to sort out before it's ready to merge:
The big ones:
- DataCollector is never imported. The model still uses it directly but the import cell only has import mesa and import pandas as pd. You'll get a NameError when you run it. Either add from mesa.datacollection import DataCollector or switch to mesa.DataCollector(...) in the model.
- df["BurnedOut"] needs to be df["Burned Out"] (with a space). The reporter key in DataCollector is Burned Out, so that's what batch_run will name the column. Without the space it'll throw a KeyError.
Smaller things:
- There's a # this is fix by vanya comment left in deffuant_weisbuch/model.py worth removing before merging!
- The notebook still has the old error tracebacks in some cells. Could you do a clean run in a Mesa 4 environment and recommit with fresh outputs?
Once those are fixed this should be good to go!
Thanks for your feedback.I have made the changes please see to it
Keep your git history clean
Keep your git history clean
done @codebreaker32
@EwoutH @jackiekazil @catherinedevlin this pr is ready to be merged!