Update easy function

mesa
J. Fernando Sánchez 1 year ago
parent b3e77cbff5
commit 1d882dcff6

@ -2,6 +2,8 @@ This example can be run like with command-line options, like this:
```bash
python cars.py --level DEBUG -e summary --csv
#or
soil cars.py -e summary
```
This will set the `CSV` (save the agent and model data to a CSV) and `summary` (print the a summary of the data to stdout) exporters, and set the log level to DEBUG.

@ -223,4 +223,4 @@ simulation = Simulation(name="RideHailing",
model_params=dict(n_passengers=2))
if __name__ == "__main__":
simulation.run()
easy(simulation)

@ -33,7 +33,6 @@ def main(
num_processes=1,
output="soil_output",
*,
do_run=False,
debug=False,
pdb=False,
**kwargs,
@ -234,10 +233,7 @@ def main(
if args.only_convert:
print(sim.to_yaml())
continue
if do_run:
res.append(sim.run(until=args.until))
else:
res.append(sim)
res.append(sim.run(until=args.until))
except Exception as ex:
if args.pdb:
@ -258,7 +254,7 @@ def main(
@contextmanager
def easy(cfg, pdb=False, debug=False, **kwargs):
try:
yield main(cfg, debug=debug, pdb=pdb, **kwargs)[0]
return main(cfg, debug=debug, pdb=pdb, **kwargs)[0]
except Exception as e:
if os.environ.get("SOIL_POSTMORTEM"):
from .debugging import post_mortem
@ -269,4 +265,4 @@ def easy(cfg, pdb=False, debug=False, **kwargs):
if __name__ == "__main__":
main(do_run=True)
main()

@ -2,8 +2,8 @@ from . import main as init_main
def main():
init_main(do_run=True)
init_main()
if __name__ == "__main__":
init_main(do_run=True)
init_main()

@ -137,7 +137,7 @@ class TimedActivation(BaseScheduler):
if not self.model.running or self.time == INFINITY:
return
self.logger.debug("Queue length: {ql}", ql=len(self._queue))
self.logger.debug(f"Queue length: %s", len(self._queue))
while self._queue:
((when, _id, cond), agent) = self._queue[0]
@ -157,7 +157,7 @@ class TimedActivation(BaseScheduler):
agent._last_return = None
agent._last_except = None
self.logger.debug("Stepping agent {agent}", agent=agent)
self.logger.debug("Stepping agent %s", agent)
self._next.pop(agent.unique_id, None)
try:

Loading…
Cancel
Save