Skip to content

Error when using ParticleMonitor in feature/multibunch_feedback #105

@michuschenk

Description

@michuschenk

When using ParticleMonitor in multi-bunch branch, the following error occurs, coming from
line 454
dims = bunch.get_coords_n_momenta_dict().values()[0][::self.stride].shape

leads to:

Traceback (most recent call last):
File "sps_multibunch.py", line 212, in
run(xi=xi)
File "sps_multibunch.py", line 188, in run
particlemonitor_dict[str(bb.bucket_id[0])].dump(bb)
File "/hpcscratch/user/mischenk/PyHEADTAIL/monitors/monitors.py", line 424, in dump
self.write_data_to_file(bunch, arrays_dict)
File "/hpcscratch/user/mischenk/PyHEADTAIL/monitors/monitors.py", line 454, in write_data_to_file
dims = bunch.get_coords_n_momenta_dict().values()[0][::self.stride].shape # more robust implementation
File "/hpcscratch/user/mischenk/PyHEADTAIL/particles/particles.py", line 203, in get_coords_n_momenta_dict
return {coord: getattr(self, np.copy('
'+coord)) for coord in self.coords_n_momenta}
File "/hpcscratch/user/mischenk/PyHEADTAIL/particles/particles.py", line 203, in
return {coord: getattr(self, np.copy('
'+coord)) for coord in self.coords_n_momenta}
TypeError: getattr(): attribute name must be string

Bug is linked to ParticleView(..) class. Permanent fix desired, but there is a workaround for now::
Comment out line 454 and use line 453 instead (solution less robust according to comment in code):

dims = (bunch.macroparticlenumber // self.stride,)

Thanks to Hannes and Carlo for spotting the error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions