-
Notifications
You must be signed in to change notification settings - Fork 29
Description
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.