Skip to content

Commit b547ee3

Browse files
committed
fix: Fallback to None when attribute is missing
1 parent 2162451 commit b547ee3

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

examples/bank_reserves/bank_reserves/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def __init__(
134134
"Money": get_total_money,
135135
"Loans": get_total_loans,
136136
},
137-
agent_reporters={"Wealth": lambda x: x.wealth},
137+
agent_reporters={"Wealth": lambda x: getattr(x, "wealth", None)},
138138
)
139139

140140
# create a single bank for the model

examples/charts/charts/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def __init__(
117117
"Money": get_total_money,
118118
"Loans": get_total_loans,
119119
},
120-
agent_reporters={"Wealth": lambda x: x.wealth},
120+
agent_reporters={"Wealth": lambda x: getattr(x, "wealth", None)},
121121
)
122122

123123
# create a single bank for the model

0 commit comments

Comments
 (0)