Commit 2123256f authored by Gaetano Scandariato's avatar Gaetano Scandariato
Browse files

feat: Update GP parsing to deprecate 'log_gp_lengthscale' and improve logging...

feat: Update GP parsing to deprecate 'log_gp_lengthscale' and improve logging for parameter initialization
parent ac688064
Loading
Loading
Loading
Loading
Loading
+10 −5
Changes for PyAETNA/sampling/config/parser/gp.py: 10 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -16,6 +16,15 @@ def parse_gp(detrending, plModel, inst_names, inst_name_to_idx, inst_name_to_id,
        if not isinstance(gp_cfg, dict):
            continue

        if 'log_gp_lengthscale' in gp_cfg:
            msg = (
                f"GP '{gp_name}': 'log_gp_lengthscale' is deprecated and no longer supported. "
                f"Please update your configuration file to use 'log_gp_scale' instead."
            )
            if log_func is not None:
                log_func(plModel, f"ERROR: {msg}")
            raise ValueError(msg)

        kernel_type = gp_cfg.get('kernel', None)
        if kernel_type is None or str(kernel_type).lower() == 'none':
            continue
@@ -81,9 +90,6 @@ def parse_gp(detrending, plModel, inst_names, inst_name_to_idx, inst_name_to_id,
        for param_key in (param_order if param_order else []):
            cfg_key = param_key
            if cfg_key not in gp_cfg:
                if cfg_key == 'log_gp_lengthscale' and 'log_gp_scale' in gp_cfg:
                    cfg_key = 'log_gp_scale'
                else:
                continue
            raw_value = resolve_config_value(
                gp_cfg[cfg_key], named_priors, f"detrending.GP.{gp_name}.{cfg_key}"
@@ -162,8 +168,7 @@ def parse_gp(detrending, plModel, inst_names, inst_name_to_idx, inst_name_to_id,
            for param_key in (param_order if param_order else []):
                cfg_key = param_key
                if cfg_key not in gp_cfg:
                    if cfg_key == 'log_gp_lengthscale' and 'log_gp_scale' in gp_cfg:
                        cfg_key = 'log_gp_scale'
                    continue

                if param_key not in parsed_params:
                    indexed_keys = [k for k in parsed_params.keys() if k.startswith(f'{param_key}_') and k[len(param_key)+1:].split('_')[0].isdigit()]
+10 −2
Changes for PyAETNA/sampling/engine/logging.py: 10 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -111,8 +111,16 @@ def check_walker_initialization(mcmc_obj, plModel, log_func, prob_fn=None, plDat
        log_func(plModel, header)
        log_func(plModel, separator)

        # Rows for each sampling parameter
        for param_name, z_array in z_values.items():
        # Rows for each sampling parameter ordered to match param_config['free_params'] (same as WARMUP STATES SUMMARY)
        if plModel is not None and hasattr(plModel, 'param_config') and plModel.param_config and 'free_params' in plModel.param_config:
            free_param_order = list(plModel.param_config['free_params'].keys())
            param_items = [(p, z_values[p]) for p in free_param_order if p in z_values]
            # Include any remaining z_values keys not in free_params
            param_items += [(p, z_values[p]) for p in z_values if p not in free_param_order]
        else:
            param_items = list(z_values.items())

        for param_name, z_array in param_items:
            row_vals = []
            for i in range(num_walkers):
                z_val = float(z_array[i])