Skip to content

Commit

Permalink
rename add_constraint argument
Browse files Browse the repository at this point in the history
  • Loading branch information
peterstangl committed Jul 16, 2024
1 parent e261bfb commit 99ad995
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions flavio/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ def all_parameters(self):
"""Returns a list of all parameters/observables constrained."""
return list(self._parameters.keys())

def add_constraint(self, parameters, constraint, parameter_object=False):
def add_constraint(self, parameters, constraint, is_parameter_constraint=None):
"""Set the constraint on one or several parameters/observables.
`constraint` must be an instance of a child of ProbabilityDistribution.
Note that if there already exists a constraint, it will be removed."""
for num, parameter in enumerate(parameters):
if parameter_object:
if is_parameter_constraint:
try: # check if parameter object already exists
p = Parameter[parameter]
except: # otherwise, create a new one
Expand Down
2 changes: 1 addition & 1 deletion flavio/physics/bdecays/formfactors/b_p/bcl_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ def load_parameters(filename, constraints):
ff_dict = yaml.safe_load(f)
covariance = np.outer(ff_dict['uncertainties'], ff_dict['uncertainties'])*ff_dict['correlation']
constraints.add_constraint(ff_dict['parameters'],
MultivariateNormalDistribution(central_value=ff_dict['central_values'], covariance=covariance), parameter_object=True)
MultivariateNormalDistribution(central_value=ff_dict['central_values'], covariance=covariance), is_parameter_constraint=True)
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ def load_parameters(filename, constraints):
raise ValueError('No f or b in observable name')
observables_renamed.append(o[:index]+ ' BCL ' + o[index:])
constraints.add_constraint(observables_renamed,
MultivariateNormalDistribution(central_value=central_values, covariance=covariance), parameter_object=True)
MultivariateNormalDistribution(central_value=central_values, covariance=covariance), is_parameter_constraint=True)
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def load_parameters(file_res, file_cov, process, constraints):
- np.diag([ cov_dict[(k,k)] for k in keys_sorted]) )
parameter_names = [implementation_name + ' ' + coeff_name for coeff_name in keys_sorted]
constraints.add_constraint(parameter_names,
MultivariateNormalDistribution(central_value=res, covariance=cov ), parameter_object=True)
MultivariateNormalDistribution(central_value=res, covariance=cov ), is_parameter_constraint=True)


def lattice_load(constraints):
Expand Down

0 comments on commit 99ad995

Please sign in to comment.