From b547ee3381a22a2b95334b4c1a32a6caf33ed189 Mon Sep 17 00:00:00 2001 From: rht Date: Wed, 24 Jan 2024 04:02:58 -0500 Subject: [PATCH] fix: Fallback to None when attribute is missing --- examples/bank_reserves/bank_reserves/model.py | 2 +- examples/charts/charts/model.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/bank_reserves/bank_reserves/model.py b/examples/bank_reserves/bank_reserves/model.py index 993c2d40..f0f4ba77 100644 --- a/examples/bank_reserves/bank_reserves/model.py +++ b/examples/bank_reserves/bank_reserves/model.py @@ -134,7 +134,7 @@ def __init__( "Money": get_total_money, "Loans": get_total_loans, }, - agent_reporters={"Wealth": lambda x: x.wealth}, + agent_reporters={"Wealth": lambda x: getattr(x, "wealth", None)}, ) # create a single bank for the model diff --git a/examples/charts/charts/model.py b/examples/charts/charts/model.py index 8f300643..71e984a1 100644 --- a/examples/charts/charts/model.py +++ b/examples/charts/charts/model.py @@ -117,7 +117,7 @@ def __init__( "Money": get_total_money, "Loans": get_total_loans, }, - agent_reporters={"Wealth": lambda x: x.wealth}, + agent_reporters={"Wealth": lambda x: getattr(x, "wealth", None)}, ) # create a single bank for the model