Skip to content

Need to fix Line arguments to List instead of Tuple #45

@aoeftiger

Description

@aoeftiger

... otherwise Line.append_element does not work.

line = pysixtrack.elements.Line()

line.append_element(
    pysixtrack.elements.Multipole(knl=[0, 1e-2]), 
    'multipole')

... throws a

AttributeError                            Traceback (most recent call last)
<ipython-input-22-7a02c560d482> in <module>
      3 line.append_element(
      4     pysixtrack.elements.Multipole(knl=[0, 1e-2]),
----> 5     'multipole')
      6 line.append_element(
      7     pysixtrack.elements.DriftExact(length=1),

~/gsi/git/pysixtrack/pysixtrack/line.py in append_element(self, element, name)
     83 
     84     def append_element(self, element, name):
---> 85         self.elements.append(element)
     86         self.element_names.append(name)
     87         # assert len(self.elements) == len(self.element_names)

AttributeError: 'tuple' object has no attribute 'append'

... while initialising the kwargs elements and element_names with empty List instances instead of the default empty Tuple instances resolves the problem:

pysixtrack.elements.Line(elements=[], element_names=[])

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