File tree Expand file tree Collapse file tree 4 files changed +31
-4
lines changed
tests/framework/population Expand file tree Collapse file tree 4 files changed +31
-4
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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"
Original file line number Diff line number Diff 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 (
Original file line number Diff line number Diff line change 44from typing import Union
55
66import pandas as pd
7- import pandas .testing as pdt
87import pytest
98
109from 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##################################################
You can’t perform that action at this time.
0 commit comments