You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python: useful error when initialize_warpx not called before creating ParticleContainerWrapper (#5412)
Currently, WarpX is initialized when `sim.step` is called, or when the
user calls `initialize_warpx`. However, if the user tries to create a
`ParticleContainerWrapper` before this point, they get an error along
the following lines:
```
File "/home/marksta/projects/warpx-ionization/picmi.py", line 185, in <module>
sim.run()
File "/home/marksta/projects/warpx-ionization/picmi.py", line 179, in run
self.elec_wrapper = particle_containers.ParticleContainerWrapper(self.electrons.name)
File "/home/marksta/.local/lib/python3.10/site-packages/pywarpx/particle_containers.py", line 29, in __init__
mypc = libwarpx.warpx.multi_particle_container()
File "/home/marksta/.local/lib/python3.10/site-packages/pywarpx/_libwarpx.py", line 46, in __getattr__
return self.__getattribute__(attribute)
AttributeError: 'LibWarpX' object has no attribute 'warpx'
```
This is confusing. When I got this, I assumed I had maybe installed
WarpX wrong. I added a catch for this exception that re-raises it with
some additional context that should help direct the user to call
`initialize_warpx`
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
0 commit comments