@@ -813,14 +813,13 @@ def n_measurements(self) -> int:
813813 """Number of measurements."""
814814 return len (self .measurement_table .measurements )
815815
816- # TODO: update after implementing priors in `Parameter`
817816 @property
818817 def n_priors (self ) -> int :
819818 """Number of priors."""
820- if OBJECTIVE_PRIOR_PARAMETERS not in self . parameter_df :
821- return 0
822-
823- return self . parameter_df [ OBJECTIVE_PRIOR_PARAMETERS ]. notna (). sum ( )
819+ return sum (
820+ p . prior_distribution is not None
821+ for p in self . parameter_table . parameters
822+ )
824823
825824 def validate (
826825 self , validation_tasks : list [ValidationTask ] = None
@@ -944,10 +943,8 @@ def add_parameter(
944943 scale : str = None ,
945944 lb : Number = None ,
946945 ub : Number = None ,
947- init_prior_type : str = None ,
948- init_prior_pars : str | Sequence = None ,
949- obj_prior_type : str = None ,
950- obj_prior_pars : str | Sequence = None ,
946+ prior_dist : str = None ,
947+ prior_pars : str | Sequence = None ,
951948 ** kwargs ,
952949 ):
953950 """Add a parameter to the problem.
@@ -959,11 +956,8 @@ def add_parameter(
959956 scale: The parameter scale
960957 lb: The lower bound of the parameter
961958 ub: The upper bound of the parameter
962- init_prior_type: The type of the initialization prior distribution
963- init_prior_pars: The parameters of the initialization prior
964- distribution
965- obj_prior_type: The type of the objective prior distribution
966- obj_prior_pars: The parameters of the objective prior distribution
959+ prior_dist: The type of the prior distribution
960+ prior_pars: The parameters of the prior distribution
967961 kwargs: additional columns/values to add to the parameter table
968962 """
969963 record = {
@@ -979,22 +973,12 @@ def add_parameter(
979973 record [LOWER_BOUND ] = lb
980974 if ub is not None :
981975 record [UPPER_BOUND ] = ub
982- if init_prior_type is not None :
983- record [INITIALIZATION_PRIOR_TYPE ] = init_prior_type
984- if init_prior_pars is not None :
985- if not isinstance (init_prior_pars , str ):
986- init_prior_pars = PARAMETER_SEPARATOR .join (
987- map (str , init_prior_pars )
988- )
989- record [INITIALIZATION_PRIOR_PARAMETERS ] = init_prior_pars
990- if obj_prior_type is not None :
991- record [OBJECTIVE_PRIOR_TYPE ] = obj_prior_type
992- if obj_prior_pars is not None :
993- if not isinstance (obj_prior_pars , str ):
994- obj_prior_pars = PARAMETER_SEPARATOR .join (
995- map (str , obj_prior_pars )
996- )
997- record [OBJECTIVE_PRIOR_PARAMETERS ] = obj_prior_pars
976+ if prior_dist is not None :
977+ record [PRIOR_DISTRIBUTION ] = prior_dist
978+ if prior_pars is not None :
979+ if not isinstance (prior_pars , str ):
980+ prior_pars = PARAMETER_SEPARATOR .join (map (str , prior_pars ))
981+ record [PRIOR_PARAMETERS ] = prior_pars
998982 record .update (kwargs )
999983
1000984 self .parameter_table += core .Parameter (** record )
@@ -1127,7 +1111,7 @@ def model_dump(self, **kwargs) -> dict[str, Any]:
11271111 'id': 'par',
11281112 'lb': 0.0,
11291113 'nominal_value': None,
1130- 'scale ': <ParameterScale.LIN: 'lin'> ,
1114+ 'prior_distribution ': None ,
11311115 'ub': 1.0}]}
11321116 """
11331117 res = {
0 commit comments