Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python: useful error when
initialize_warpx
not called before creati…
…ng `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>
- Loading branch information