@@ -73,8 +73,11 @@ def _not_nan(v: float, info: ValidationInfo) -> float:
7373
7474
7575def _convert_nan_to_none (v ):
76+ """Convert NaN or "" to None."""
7677 if isinstance (v , float ) and np .isnan (v ):
7778 return None
79+ if isinstance (v , str ) and v == "" :
80+ return None
7881 return v
7982
8083
@@ -503,12 +506,17 @@ class ExperimentPeriod(BaseModel):
503506 @field_validator ("condition_ids" , mode = "before" )
504507 @classmethod
505508 def _validate_ids (cls , condition_ids ):
506- if condition_ids in [None , []]:
509+ if condition_ids in [None , "" , [], ["" ]]:
510+ # unspecified, or "use-model-as-is"
507511 return []
508512
509513 for condition_id in condition_ids :
510- if is_valid_identifier (condition_id ):
511- raise ValueError (f"Invalid ID: `{ condition_id } '" )
514+ # The empty condition ID for "use-model-as-is" has been handled
515+ # above. Having a combination of empty and non-empty IDs is an
516+ # error, since the targets of conditions to be combined must be
517+ # disjoint.
518+ if not is_valid_identifier (condition_id ):
519+ raise ValueError (f"Invalid { C .CONDITION_ID } : `{ condition_id } '" )
512520 return condition_ids
513521
514522
@@ -899,7 +907,7 @@ def _validate_id(cls, v):
899907 @field_validator ("prior_parameters" , mode = "before" )
900908 @classmethod
901909 def _validate_prior_parameters (cls , v ):
902- if pd . isna (v ):
910+ if isinstance ( v , float ) and np . isnan (v ):
903911 return []
904912
905913 if isinstance (v , str ):
@@ -969,7 +977,7 @@ def _validate(self) -> Self:
969977
970978 @property
971979 def prior_dist (self ) -> Distribution :
972- """Get the pior distribution of the parameter."""
980+ """Get the prior distribution of the parameter."""
973981 if self .estimate is False :
974982 raise ValueError (f"Parameter `{ self .id } ' is not estimated." )
975983
@@ -997,6 +1005,13 @@ def prior_dist(self) -> Distribution:
9971005 "transformation."
9981006 )
9991007 return cls (* self .prior_parameters , trunc = [self .lb , self .ub ])
1008+
1009+ if cls == Uniform :
1010+ # `Uniform.__init__` does not accept the `trunc` parameter
1011+ low = max (self .prior_parameters [0 ], self .lb )
1012+ high = min (self .prior_parameters [1 ], self .ub )
1013+ return cls (low , high , log = log )
1014+
10001015 return cls (* self .prior_parameters , log = log , trunc = [self .lb , self .ub ])
10011016
10021017
0 commit comments