Skip to content

Fix initialization of the components of an elements group

Currently the initialization of the components of an ElementsGroup is done as follows:

comp_dict = defaultdict(int)
for element in elements_list:
    for c in element.components:
        comp_dict[(c.plane, c.source_exponents, c.test_exponents)] += c

components = comp_dict.values()
self.components = sorted(components, key=lambda x: (x.plane, x.source_exponents, 
                                                                x.test_exponents))

but this way the beta weighting is forgotten.

We substitute this part of code with

self.components = sum(elements_list).components

Which does the weighting correctly and is super compact.

The same change is done in CollimatorsGroup and EllipticElementsGroup

Edited by Lorenzo Giacomel

Merge request reports