Skip to content

Update CollectionBase to allow NewBase elements #203

@henrikjacobsenfys

Description

@henrikjacobsenfys

This is needed by MultiFitter. See e.g. here for error: https://github.com/easyscience/dynamics-lib/actions/runs/22091445771/job/63837421005?pr=100

Relevant excerpt below:

--> 351 mf = MultiFitter(
    352 fit_objects=self.analysis_list,
    353 fit_functions=self.get_fit_functions(),
    354 )
    356 results = mf.fit(
    357     x=xs,
    358     y=ys,
    359     weights=ws,
    360 )
    361 return results

File ~/work/dynamics-lib/dynamics-lib/.pixi/envs/default/lib/python3.12/site-packages/easyscience/fitting/multi_fitter.py:27, in MultiFitter.__init__(self, fit_objects, fit_functions)
     21 def __init__(
     22     self,
     23     fit_objects: Optional[List] = None,
     24     fit_functions: Optional[List[Callable]] = None,
     25 ):
     26     # Create a dummy core object to hold all the fit objects.
---> 27     self._fit_objects = CollectionBase('multi',*fit_objects)
     28     self._fit_functions = fit_functions
     29     # Initialize with the first of the fit_functions, without this it is
     30     # not possible to change the fitting engine.

File ~/work/dynamics-lib/dynamics-lib/.pixi/envs/default/lib/python3.12/site-packages/easyscience/base_classes/collection_base.py:68, in CollectionBase.__init__(self, name, interface, unique_name, *args, **kwargs)
     66 for item in list(kwargs.values()) + _args:
     67     if not issubclass(type(item), (DescriptorBase, BasedBase)):
---> 68         raise AttributeError('A collection can only be formed from easyscience objects.')
     69 args = _args
     70 _kwargs = {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    [area] base classesChanges to or creation of new base classes[priority] highestUrgent. Needs attention ASAP[scope] bugBug report or fix (major.minor.PATCH)

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions