From 3d751f06413d4929f2be6522bec127139d10bc96 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Thu, 12 Dec 2024 09:51:35 +0100 Subject: [PATCH] Fix Prior.from_par_dict for missing priorParameters columns Previously, missing `*PriorParameters` would have resulted in a KeyError. --- petab/v1/priors.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/petab/v1/priors.py b/petab/v1/priors.py index f0f37f75..e1263946 100644 --- a/petab/v1/priors.py +++ b/petab/v1/priors.py @@ -224,10 +224,8 @@ def from_par_dict( dist_type = C.PARAMETER_SCALE_UNIFORM pscale = d.get(C.PARAMETER_SCALE, C.LIN) - if ( - pd.isna(d[f"{type_}PriorParameters"]) - and dist_type == C.PARAMETER_SCALE_UNIFORM - ): + params = d.get(f"{type_}PriorParameters", None) + if pd.isna(params) and dist_type == C.PARAMETER_SCALE_UNIFORM: params = ( scale(d[C.LOWER_BOUND], pscale), scale(d[C.UPPER_BOUND], pscale), @@ -236,7 +234,7 @@ def from_par_dict( params = tuple( map( float, - d[f"{type_}PriorParameters"].split(C.PARAMETER_SEPARATOR), + params.split(C.PARAMETER_SEPARATOR), ) ) return Prior(