Skip to content

Commit

Permalink
reap variables to dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
sbenthall committed Jul 23, 2020
1 parent 7444dc5 commit e6f1022
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions HARK/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,10 @@ def __init__(self, agents=None, sow_vars=None, reap_vars=None, const_vars=None,
None
'''
self.agents = agents if agents is not None else list() # NOQA
self.reap_vars = reap_vars if reap_vars is not None else list() # NOQA

reap_vars = reap_vars if reap_vars is not None else list() # NOQA
self.reap_vars = OrderedDict([(var, []) for var in reap_vars])

This comment has been minimized.

Copy link
@alanlujan91

alanlujan91 Apr 12, 2023

Member

it seems here we had reap_vars and self.reap_vars, which at some point becomes self.reap_state, but I don't know how to find that change in the history a6e2de9#diff-33a0fc9d7783cd0215156e3824a12904f2d025b32245aeeeeeb6b4f5cc509a74R930


self.sow_vars = sow_vars if sow_vars is not None else list() # NOQA

const_vars = const_vars if const_vars is not None else list() # NOQA
Expand Down Expand Up @@ -1032,7 +1035,7 @@ def reap(self):
harvest = []
for this_type in self.agents:
harvest.append(getattr(this_type, var_name))
setattr(self, var_name, harvest)
self.reap_vars[var_name] = harvest

def sow(self):
'''
Expand Down Expand Up @@ -1067,11 +1070,7 @@ def mill(self):
none
'''
# Make a dictionary of inputs for the millRule
reap_vars_string = ''
for name in self.reap_vars:
reap_vars_string += ' \'' + name + '\' : self.' + name + ','

mill_dict = eval('{' + reap_vars_string + '}')
mill_dict = copy(self.reap_vars)
mill_dict.update(self.const_vars)

# Run the millRule and store its output in self
Expand Down

0 comments on commit e6f1022

Please sign in to comment.