Skip to content

Clarify the way to update likelihood parameter values #12

@andreufont

Description

@andreufont

While reviewing the likelihood module, I noticed this code around line 183.

        # fill in the free parameters
        # free parameter names must match the order of values
        fp_index = 0
        for i,p in enumerate(params):
            if p.name in self.free_param_names:
                # translate the value in [0,1] to the actual parameter value
                free_param_value = p.value_from_cube(values[fp_index])
                params[i] = LikelihoodParameter(
                    name=p.name,
                    min_value=p.min_value,
                    max_value=p.max_value,
                    value=free_param_value)
                fp_index += 1

I found this confusing, since you shouldn't need to use params[i] in that loop, you already have p pointing to that element in the list (thanks to enumerate). Shouldn't you be able to do this?

        # fill in the free parameters
        # free parameter names must match the order of values
        fp_index = 0
        for i,p in enumerate(params):
            if p.name in self.free_param_names:
                p.set_from_cube(values[fp_index])
                fp_index += 1

This is not a bug or something urgent to fix, but I was wondering whether it had a deeper explanation that I'm missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions