diff --git a/flepimop/gempyor_pkg/src/gempyor/compartments.py b/flepimop/gempyor_pkg/src/gempyor/compartments.py index 25ec19406..51ce16993 100644 --- a/flepimop/gempyor_pkg/src/gempyor/compartments.py +++ b/flepimop/gempyor_pkg/src/gempyor/compartments.py @@ -283,7 +283,7 @@ def fromFile(self, compartments_file, transitions_file): return - def get_comp_idx(self, comp_dict: dict) -> int: + def get_comp_idx(self, comp_dict: dict, error_info: str = "no information") -> int: """ return the index of a compartiment given a filter. The filter has to isolate a compartiment, but it ignore columns that don't exist: @@ -294,7 +294,7 @@ def get_comp_idx(self, comp_dict: dict) -> int: comp_idx = self.compartments[mask].index.values if len(comp_idx) != 1: raise ValueError( - f"The provided dictionary does not allow to isolate a compartment: {comp_dict} isolate {self.compartments[mask]} from options {self.compartments}" + f"The provided dictionary does not allow to isolate a compartment: {comp_dict} isolate {self.compartments[mask]} from options {self.compartments}. The get_comp_idx function was called by'{error_info}'." ) return comp_idx[0] diff --git a/flepimop/gempyor_pkg/src/gempyor/seeding_ic.py b/flepimop/gempyor_pkg/src/gempyor/seeding_ic.py index 8da628cb8..7dcdacee3 100644 --- a/flepimop/gempyor_pkg/src/gempyor/seeding_ic.py +++ b/flepimop/gempyor_pkg/src/gempyor/seeding_ic.py @@ -50,8 +50,8 @@ def _DataFrame2NumbaDict(df, amounts, setup) -> nb.typed.Dict: ) source_dict = {grp_name: row[f"source_{grp_name}"] for grp_name in cmp_grp_names} destination_dict = {grp_name: row[f"destination_{grp_name}"] for grp_name in cmp_grp_names} - seeding_dict["seeding_sources"][idx] = setup.compartments.get_comp_idx(source_dict) - seeding_dict["seeding_destinations"][idx] = setup.compartments.get_comp_idx(destination_dict) + seeding_dict["seeding_sources"][idx] = setup.compartments.get_comp_idx(source_dict, error_info = f"(seeding source at idx={idx}, row_index={row_index}, row=>>{row}<<)") + seeding_dict["seeding_destinations"][idx] = setup.compartments.get_comp_idx(destination_dict, error_info = f"(seeding destination at idx={idx}, row_index={row_index}, row=>>{row}<<)") seeding_dict["seeding_subpops"][idx] = setup.subpop_struct.subpop_names.index(row["subpop"]) seeding_amounts[idx] = amounts[idx] #id_seed+=1