Skip to content

Commit

Permalink
Merge branch 'breaking-improvments' of https://github.com/HopkinsIDD/…
Browse files Browse the repository at this point in the history
…flepiMoP into breaking-improvments
  • Loading branch information
alsnhll committed Nov 15, 2023
2 parents 94ba77b + 4cbe458 commit 82e7d68
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: |
source /var/python/3.10/virtualenv/bin/activate
python -m pip install --upgrade pip
python -m pip install flepimop/gempyor_pkg/
python -m pip install "flepimop/gempyor_pkg[test]"
shell: bash
- name: Install local R packages
run: Rscript build/local_install.R
Expand Down
9 changes: 8 additions & 1 deletion flepimop/gempyor_pkg/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@ install_requires =
pyarrow
sympy
dask
pytest
scipy
graphviz

# see https://stackoverflow.com/questions/58826164/dependencies-requirements-for-setting-up-testing-and-installing-a-python-lib
# installed for pip install -e ".[test]"
[options.extras_require]
test =
pytest
mock


[options.entry_points]
console_scripts =
gempyor-outcomes = gempyor.simulate_outcome:simulate
Expand Down
6 changes: 3 additions & 3 deletions flepimop/gempyor_pkg/src/gempyor/compartments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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]

Expand Down Expand Up @@ -476,7 +476,7 @@ def parse_parameter_strings_to_numpy_arrays_v2(self, parameters, parameter_names
f = sp.sympify(formula, locals=symbolic_parameters_namespace)
parsed_formulas.append(f)
except Exception as e:
print(f"Cannot parse formula: '{formula}' from paramters {parameter_names}")
print(f"Cannot parse formula: '{formula}' from parameters {parameter_names}")
raise (e) # Print the error message for debugging

# the list order needs to be right.
Expand Down
13 changes: 3 additions & 10 deletions flepimop/gempyor_pkg/src/gempyor/seeding_ic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -326,14 +326,7 @@ def draw_seeding(self, sim_id: int, setup) -> nb.typed.Dict:
return _DataFrame2NumbaDict(df=seeding, amounts=amounts, setup=setup)

def load_seeding(self, sim_id: int, setup) -> nb.typed.Dict:
method = "NoSeeding"

if self.seeding_config is not None and "method" in self.seeding_config.keys():
method = self.seeding_config["method"].as_str()
if method not in ["FolderDraw", "SetInitialConditions", "InitialConditionsFolderDraw", "NoSeeding", "FromFile"]:
raise NotImplementedError(
f"Seeding method in inference run must be FolderDraw, SetInitialConditions, FromFile or InitialConditionsFolderDraw [got: {method}]"
)
""" only difference with draw seeding is that the sim_id is now sim_id2load"""
return self.draw_seeding(sim_id=sim_id, setup=setup)

def load_ic(self, sim_id: int, setup) -> nb.typed.Dict:
Expand Down

0 comments on commit 82e7d68

Please sign in to comment.