def modify_parameter(param: ParameterBase, field: str, value: object) -> None: if hasattr(param, field): setattr(param, field, value) else: param.data[field] = value param.save() signals.parameters_changed.emit()
def modify_parameter(self, param: ParameterBase, field: str, value: Union[str, float, list]) -> None: with bw.parameters.db.atomic() as transaction: try: if hasattr(param, field): setattr(param, field, value) elif field == "order": # Store the given order in the Group used by the parameter if param.group in value: value.remove(param.group) group = Group.get(name=param.group) group.order = value group.expire() else: param.data[field] = value param.save() bw.parameters.recalculate() except Exception as e: # Anything wrong? Roll the transaction back and throw up a # warning message. transaction.rollback() QMessageBox.warning( self.window, "Could not save changes", str(e), QMessageBox.Ok, QMessageBox.Ok ) signals.parameters_changed.emit()
def modify_parameter_uncertainty(param: ParameterBase, uncertain: dict) -> None: unc_fields = {"loc", "scale", "shape", "minimum", "maximum"} for k, v in uncertain.items(): if k in unc_fields and isinstance(v, str): # Convert empty values into nan, accepted by stats_arrays v = float("nan") if not v else float(v) param.data[k] = v param.save() signals.parameters_changed.emit()
def modify_parameter_pedigree(param: ParameterBase, pedigree: dict) -> None: param.data["pedigree"] = pedigree param.save() signals.parameters_changed.emit()