AB-CE / abce

Agent-based computational Economics, the Python library that makes AB modelling easier
http://abce.readthedocs.io
190 stars 64 forks source link

NotEnoughGoods called without needed arguments in Firm produce() #216

Closed glysbaysb closed 3 years ago

glysbaysb commented 3 years ago

If a firm does not have enough goods for its production function it throws the NotEnoughGoods exception. However it does not pass the required parameters in the constructor making it impossible to handle this error.

  File "/home/a/code/econ/abce/examples/economy/bakery.py", line 41, in production
    self.produce(self.pf, self.inputs)
  File "/home/a/.local/lib/python3.8/site-packages/abcEconomics/agents/firm.py", line 130, in produce
    raise NotEnoughGoods
TypeError: __init__() missing 3 required positional arguments: '_agent_name', 'good', and 'amount_missing'

See https://github.com/AB-CE/abce/blob/master/abcEconomics/agents/firm.py#L130

rht commented 3 years ago

@glysbaysb thanks for the report. Made a fix in https://github.com/AB-CE/abce/commit/296216dbff9b2a4810f245d3a94544c46e68691b. Let me know if it fixes the bug.

glysbaysb commented 3 years ago

Yes that works perfectly, sorry it took me a while to reply.