Skip to content

Commit 7c31082

Browse files
authored
Merge pull request #216 from ihmeuw/develop
Develop
2 parents 25369b6 + 615f372 commit 7c31082

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
**0.10.16 - 06/30/22**
2+
3+
- Fix a bug in adding new simulants to a population
4+
15
**0.10.15 - 06/29/22**
26

37
- Added performance reporting

src/vivarium/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
__summary__ = "vivarium is a microsimulation framework built on top of the standard scientific python stack."
1414
__uri__ = "https://github.com/ihmeuw/vivarium"
1515

16-
__version__ = "0.10.15"
16+
__version__ = "0.10.16"
1717

1818
__author__ = "The vivarium developers"
1919
__email__ = "vivarium.dev@gmail.com"

src/vivarium/framework/population/population_view.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,14 @@ def _format_update_and_check_preconditions(
329329
)
330330

331331
if adding_simulants:
332+
state_table_new_simulants = state_table.loc[population_update.index, :]
332333
conflicting_columns = [
333334
column
334335
for column in population_update
335-
if state_table.loc[population_update.index, column].notnull().any()
336-
and not population_update[column].equals(state_table[column])
336+
if state_table_new_simulants[column].notnull().any()
337+
and not population_update[column].equals(
338+
state_table_new_simulants[column]
339+
)
337340
]
338341
if conflicting_columns:
339342
raise PopulationError(

tests/framework/population/test_population_view.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from typing import Union
55

66
import pandas as pd
7-
import pandas.testing as pdt
87
import pytest
98

109
from vivarium.framework.population import (
@@ -594,6 +593,27 @@ def test__format_update_and_check_preconditions_time_step_pass(
594593
assert result[col].equals(update[col])
595594

596595

596+
def test__format_update_and_check_preconditions_adding_simulants_replace_identical_data(
597+
population_update,
598+
update_index,
599+
):
600+
result = PopulationView._format_update_and_check_preconditions(
601+
population_update,
602+
BASE_POPULATION,
603+
COL_NAMES + NEW_COL_NAMES,
604+
False,
605+
True,
606+
)
607+
update = PopulationView._coerce_to_dataframe(
608+
population_update,
609+
COL_NAMES + NEW_COL_NAMES,
610+
)
611+
612+
assert set(result.columns) == set(update)
613+
for col in update:
614+
assert result[col].equals(update[col])
615+
616+
597617
#################################
598618
# PopulationView.update helpers #
599619
##################################################

0 commit comments

Comments
 (0)