Skip to content

Fix EasyList to accept a list of parameters #307

Closed

Description

@rozyczko

As noted in #306 (comment) we should be able to instantiate EasyList with a simple list/tuple of parameters.

E.g.

el = EasyList(Parameter('a', value=1.0), Parameter('b', value=2.0))

Currently, EasyList drops those kwargs, as EasyList overrides get_all_variables to only recurse into ModelBase items, not simple sequences and bare descriptors are dropped.

el.get_all_variables()   # []
el.get_fit_parameters()  # []

I am marking this as a bug since any sane person would expect a simple list to be accepted for fitting.

Activity

  1. added
    [scope] bug
    [priority] highest
    [area] base classes
    on Sep 15, 2026
  2. rozyczko commented on Sep 15, 2026

    @rozyczko
    MemberAuthor

    This might be as simple as adding this snippet to EasyList.get_all_variables()

    for item in self._data:
        if isinstance(item, DescriptorBase):
            all_vars.append(item)
        elif isinstance(item, ModelBase):
            all_vars.extend(item.get_all_variables())
  3. damskii9992 commented on Sep 16, 2026

    @damskii9992
    Contributor

    This might be as simple as adding this snippet to EasyList.get_all_variables()

    for item in self._data:
    if isinstance(item, DescriptorBase):
    all_vars.append(item)
    elif isinstance(item, ModelBase):
    all_vars.extend(item.get_all_variables())

    Yes, I believe that is all we need to add, except it should be DescriptorNumber, not DescriptorBase ;)

  4. rozyczko commented on Sep 16, 2026

    @rozyczko
    MemberAuthor

    This might be as simple as adding this snippet to EasyList.get_all_variables()
    for item in self._data:
    if isinstance(item, DescriptorBase):
    all_vars.append(item)
    elif isinstance(item, ModelBase):
    all_vars.extend(item.get_all_variables())

    Yes, I believe that is all we need to add, except it should be DescriptorNumber, not DescriptorBase ;)

    Nope.
    DescriptorBase matches ModelBase. ModelBase already tests isinstance(attr, DescriptorBase). EasyList overrides it and declares the same return type, so it should respond in the same way a ModelBase would. This EasyList override should NOT be stricter than the method it overrides.
    Also, the fitting filter is applied anyway get_all_parameters() keeps only Parameter instances, and get_fittable_parameters and get_free_parameters go even deeper. So using DescriptorBase costs nothing here and would be more consistent.
    get_fit_parameters will still return only Parameters.

  5. damskii9992 commented on Sep 21, 2026

    @damskii9992
    Contributor

    Huh, you're right.
    On another note though, do we even use DescriptorStrings and DescriptorBools anywhere at the moment? I don't really know where I would use them myself . . .
    But yes, DescriptorBase it is :)

  6. added a commit that references this issue on Sep 22, 2026
  7. rozyczko commented on Sep 22, 2026

    @rozyczko
    MemberAuthor

    Fixed in 922b2a3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [area] base classes[priority] highest[scope] bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions