Skip to content

Using/type setting agent/instance attributes for arithmetics in wealth model #39

Answered by jofmi
yannickoswald asked this question in Q&A
Discussion options

You must be logged in to vote

Hi Yannik,

glad you like the package!

regarding setup(), you can also overwrite __init__() instead. If you look at the source, the agent's __init__() looks just like this:

def __init__(self, model, *args, **kwargs):
    super().__init__(model)
    self.setup(*args, **kwargs)

regarding your problem self.model.agents.random() returns an iterator of agents (even if in your case it is only one agent). the iterator can support some operations but not all. an easy way to unpack the agent from the iterator is this (notice the comma after partner):

partner, = self.model.agents.random()

if you want to be more explicit, you can also use:

for partner in self.model.agents.random():
   ...

let me k…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@yannickoswald
Comment options

Answer selected by yannickoswald
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants