From c96c2d70d8ab11c7191c0955ec3237032799edd4 Mon Sep 17 00:00:00 2001 From: teddygroves Date: Mon, 16 Oct 2023 15:28:27 +0200 Subject: [PATCH] Fix setting inits --- maud/data_model/maud_input.py | 20 +++++++++++++++----- maud/data_model/maud_parameter.py | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/maud/data_model/maud_input.py b/maud/data_model/maud_input.py index ffc0f305..807215f2 100644 --- a/maud/data_model/maud_input.py +++ b/maud/data_model/maud_input.py @@ -66,9 +66,19 @@ def inits_dict(self) -> Dict: for p in self.parameters.dict().keys() if isinstance(getattr(self.parameters, p), MaudParameter) ] - for p in params: - inits_dict[p.name] = p.inits.inits_unscaled - if p.inits.inits_scaled is not None: - scaled_pref = "log_" if p.non_negative else "" - inits_dict[scaled_pref + p.name + "_z"] = p.inits.inits_scaled + for param in params: + inits_dict[param.name] = param.inits.inits_unscaled + if param.inits.inits_scaled is not None: + scaled_pref = "log_" if param.non_negative else "" + inits_dict[ + scaled_pref + param.name + "_z" + ] = param.inits.inits_scaled + if param.fixed_ids is not None: + inits_dict[param.name + "_free"] = [ + v + for k, v in zip( + param.inits.ids[0], param.inits.inits_unscaled + ) + if k not in param.fixed_ids[0] + ] return inits_dict diff --git a/maud/data_model/maud_parameter.py b/maud/data_model/maud_parameter.py index 18a60919..a22ea6f3 100644 --- a/maud/data_model/maud_parameter.py +++ b/maud/data_model/maud_parameter.py @@ -74,7 +74,7 @@ def fixed_values(self) -> Optional[List[List[float]]]: if self.user_input.fixed_values is None: return None else: - return list(self.user_input.fixed_values.values()) + return [list(self.user_input.fixed_values.values())] else: raise ValueError(f"Something wrong with input {self.user_input}")