From 55b90241a4e352f3a3ca67918c28fc4ab1587e4d Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Tue, 14 May 2024 16:11:06 -0700 Subject: [PATCH] Fix Sole Run of `test_charge_deposition.py` Ensure this test can still be run like a script, not only with PyTest. Execute: ``` python tests/python/test_charge_deposition.py ``` --- tests/python/test_charge_deposition.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/python/test_charge_deposition.py b/tests/python/test_charge_deposition.py index 38093e852..1b2037c62 100755 --- a/tests/python/test_charge_deposition.py +++ b/tests/python/test_charge_deposition.py @@ -14,15 +14,14 @@ import numpy as np from conftest import basepath -import amrex.space3d as amr -import impactx +from impactx import ImpactX, amr def test_charge_deposition(save_png=True): """ Deposit charge and access/plot it """ - sim = impactx.ImpactX() + sim = ImpactX() sim.n_cell = [16, 24, 32] sim.load_inputs_file(basepath + "/examples/fodo/input_fodo.in") @@ -97,4 +96,9 @@ def test_charge_deposition(save_png=True): # implement a direct script run mode, so we can run this directly too, # with interactive matplotlib windows, w/o pytest if __name__ == "__main__": + amr.initialize([]) + test_charge_deposition(save_png=False) + + if amr.initialized(): + amr.finalize()