diff --git a/Documentation/CHANGELOG.md b/Documentation/CHANGELOG.md index ab306419a..bcb5ee340 100644 --- a/Documentation/CHANGELOG.md +++ b/Documentation/CHANGELOG.md @@ -42,6 +42,7 @@ PR: [#832](https://github.com/econ-ark/HARK/pull/832). See [this forthcoming REM * Fix mathematical limits of model example in `example_ConsPortfolioModel.ipynb` [#1047](https://github.com/econ-ark/HARK/pull/1047) * Update `ConsGenIncProcessModel.py` to use `calc_expectation` method [#1072](https://github.com/econ-ark/HARK/pull/1072) * Fix bug in `calc_normal_style_pars_from_lognormal_pars` due to math error. [#1076](https://github.com/econ-ark/HARK/pull/1076) +* Fix bug in `distribute_params` so that `AgentCount` parameter is updated. ### 0.11.0 diff --git a/HARK/core.py b/HARK/core.py index cc1c57f1a..19f9ba304 100644 --- a/HARK/core.py +++ b/HARK/core.py @@ -1449,7 +1449,7 @@ def distribute_params(agent, param_name, param_count, distribution): agent_set = [deepcopy(agent) for i in range(param_count)] for j in range(param_count): - agent_set[j].AgentCount = int(agent.AgentCount * param_dist.pmf[j]) + agent_set[j].assign_parameters(**{'AgentCount': int(agent.AgentCount * param_dist.pmf[j])}) # agent_set[j].__dict__[param_name] = param_dist.X[j] agent_set[j].assign_parameters(**{param_name: param_dist.X[j]}) diff --git a/HARK/tests/test_core.py b/HARK/tests/test_core.py index 6e6a74b71..0b76c6bf4 100644 --- a/HARK/tests/test_core.py +++ b/HARK/tests/test_core.py @@ -115,5 +115,6 @@ def test_distribute_params(self): self.assertTrue(all(['DiscFac' in agent.parameters for agent in self.agents])) self.assertTrue(all([self.agents[i].parameters['DiscFac'] == dist.approx(3).X[i] for i in range(3)])) + self.assertEqual(self.agents[0].parameters['AgentCount'], 1)