Skip to content

Commit

Permalink
removing model call(); adding Model init to AgentType and Market, fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sbenthall committed Feb 10, 2021
1 parent f880be6 commit 9e32a36
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_simulation(self):
"T_age": None, # Age after which simulated agents are automatically killed
}

self.agent_infinite(
self.agent_infinite.assignParameters(
**SimulationParams
) # This implicitly uses the assignParameters method of AgentType

Expand Down
26 changes: 21 additions & 5 deletions HARK/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,23 +169,36 @@ def assignParameters(self, **kwds):
-------
none
"""
self.parameters = kwds
self.parameters.update(kwds)
for key in kwds:
setattr(self, key, kwds[key])

def __call__(self, **kwds):
def get_parameter(self, name):
"""
Assign an arbitrary number of attributes to this agent, as a convenience.
See assignParameters.
Returns a parameter of this model
Parameters
----------
name : string
The name of the parameter to get
Returns
-------
value :
The value of the parameter
"""
self.assignParameters(**kwds)
return self.parameters[name]

def __eq__(self, other):
if isinstance(other, type(self)):
return self.parameters == other.parameters

return notImplemented

def __init__(self):
if not hasattr(self, 'parameters'):
self.parameters = {}

def __str__(self):

type_ = type(self)
Expand Down Expand Up @@ -261,6 +274,8 @@ def __init__(
seed=0,
**kwds
):
super().__init__()

if solution_terminal is None:
solution_terminal = NullFunc()

Expand Down Expand Up @@ -1116,6 +1131,7 @@ def __init__(
tolerance=0.000001,
**kwds
):
super().__init__()
self.agents = agents if agents is not None else list() # NOQA

reap_vars = reap_vars if reap_vars is not None else list() # NOQA
Expand Down

0 comments on commit 9e32a36

Please sign in to comment.