You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Acceptance criteria: validate inputs and handle compartments, missing populations and final-year windows #559
The acceptance_criteria mechanism (rejection sampling on a windowed mean of a variable) has several unhandled edge cases, all reproduced on the branch:
Naming a compartment or characteristic instead of a parameter raises AttributeError: 'Compartment' object has no attribute '_is_dynamic'.
Naming a population that does not exist raises KeyError: 'evaluate_at' when sorting, because the setup loop never assigned the key.
A t_range ending at or after the final simulation year raises IndexError in np.where(self.t > t_range[1])[0].
If no (parameter, population) match is found at evaluation time, a_t_val is unbound.
acceptance_criteria=[] is a mutable default in run_sim, run_sampled_sims, _run_sampled_sim, run_model and Model.__init__, and the dicts are mutated in place (evaluate_at, assessed_value).
Implementation plan
Validate criteria in Model.build(): check the variable exists in the named population via self.get_pop(pop).get_variable(name), raise ModelError naming the offending criterion otherwise.
Support compartments, characteristics and parameters uniformly: treat anything without _is_dynamic (compartments, characteristics) as evaluable at runtime, and parameters according to _is_dynamic.
If t_range[1] >= self.t[-1], set evaluate_at = np.inf so the criterion is checked in the final evaluate_all pass.
Change defaults to None and copy the criteria list in Model.__init__ (already deep-copied, so just fix the signatures).
Add a small AcceptanceCriterion dataclass or at least a documented schema, and tests for each of the cases above.
Activity