Skip to content

Commit

Permalink
diag dir per test case for concurrency (#875)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipDeegan authored Aug 4, 2024
1 parent 4b1c3fd commit 1eff256
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions pyphare/pyphare_tests/test_pharesee/test_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@

@ddt
class PatchHierarchyTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
from pyphare.pharein import global_vars
def diag_dir(self):
return diag_outputs + self._testMethodName

def setUp(self):
import pyphare.pharein as ph

global_vars.sim = None
ph.global_vars.sim = None

def config():
sim = ph.Simulation(
Expand All @@ -39,7 +40,7 @@ def config():
resistivity=0.001,
diag_options={
"format": "phareh5",
"options": {"dir": diag_outputs, "mode": "overwrite"},
"options": {"dir": self.diag_dir(), "mode": "overwrite"},
},
)

Expand Down Expand Up @@ -152,12 +153,12 @@ def vthz(x, y):
Simulator(config()).run()

def test_data_is_a_hierarchy(self):
r = Run(diag_outputs)
r = Run(self.diag_dir())
B = r.GetB(0.0)
self.assertTrue(isinstance(B, PatchHierarchy))

def test_can_read_multiple_times(self):
r = Run(diag_outputs)
r = Run(self.diag_dir())
times = (0.0, 0.1)
B = r.GetB(times)
E = r.GetE(times)
Expand All @@ -168,7 +169,7 @@ def test_can_read_multiple_times(self):
self.assertTrue(np.allclose(hier.times().astype(np.float32), times))

def test_hierarchy_is_refined(self):
r = Run(diag_outputs)
r = Run(self.diag_dir())
time = 0.0
B = r.GetB(time)
self.assertEqual(len(B.levels()), B.levelNbr())
Expand All @@ -177,19 +178,19 @@ def test_hierarchy_is_refined(self):
self.assertEqual(len(B.levels(time)), B.levelNbr(time))

def test_can_get_nbytes(self):
r = Run(diag_outputs)
r = Run(self.diag_dir())
time = 0.0
B = r.GetB(time)
self.assertGreater(B.nbytes(), 0)

def test_hierarchy_has_patches(self):
r = Run(diag_outputs)
r = Run(self.diag_dir())
time = 0.0
B = r.GetB(time)
self.assertGreater(B.nbrPatches(), 0)

def test_access_patchdatas_as_hierarchies(self):
r = Run(diag_outputs)
r = Run(self.diag_dir())
time = 0.0
B = r.GetB(time)
self.assertTrue(isinstance(B.x, PatchHierarchy))
Expand All @@ -200,7 +201,7 @@ def test_partial_domain_hierarchies(self):
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle

r = Run(diag_outputs)
r = Run(self.diag_dir())
time = 0.0
box = Box((10, 5), (18, 12.5))
B = r.GetB(time)
Expand All @@ -226,15 +227,15 @@ def test_partial_domain_hierarchies(self):
self.assertLess(Bpartial.nbrPatches(), B.nbrPatches())

def test_scalarfield_quantities(self):
r = Run(diag_outputs)
r = Run(self.diag_dir())
time = 0.0
Ni = r.GetNi(time)
Vi = r.GetVi(time)
self.assertTrue(isinstance(Ni, ScalarField))
self.assertTrue(isinstance(Vi, VectorField))

def test_sum_two_scalarfields(self):
r = Run(diag_outputs)
r = Run(self.diag_dir())
time = 0.0
Ni = r.GetNi(time)
Pe = r.GetPe(time)
Expand All @@ -243,7 +244,7 @@ def test_sum_two_scalarfields(self):
self.assertEqual(s.quantities(), ["value"])

def test_sum_with_scalar(self):
r = Run(diag_outputs)
r = Run(self.diag_dir())
time = 0.0
Ni = r.GetNi(time)
s1 = Ni + 0.1
Expand All @@ -253,7 +254,7 @@ def test_sum_with_scalar(self):
self.assertEqual(s.quantities(), ["value"])

def test_scalarfield_difference(self):
r = Run(diag_outputs)
r = Run(self.diag_dir())
time = 0.0
Ni = r.GetNi(time)
Pe = r.GetPe(time)
Expand All @@ -265,7 +266,7 @@ def test_scalarfield_difference(self):
self.assertEqual(s.quantities(), ["value"])

def test_scalarfield_product(self):
r = Run(diag_outputs)
r = Run(self.diag_dir())
time = 0.0
Ni = r.GetNi(time)
Pe = r.GetPe(time)
Expand All @@ -276,7 +277,7 @@ def test_scalarfield_product(self):
self.assertEqual(s.quantities(), ["value"])

def test_scalarfield_division(self):
r = Run(diag_outputs)
r = Run(self.diag_dir())
time = 0.0
Ni = r.GetNi(time)
Pe = r.GetPe(time)
Expand All @@ -289,14 +290,14 @@ def test_scalarfield_division(self):
self.assertEqual(s.quantities(), ["value"])

def test_scalarfield_sqrt(self):
r = Run(diag_outputs)
r = Run(self.diag_dir())
time = 0.0
Ni = r.GetNi(time)
nisqrt = sqrt(Ni)
self.assertTrue(isinstance(nisqrt, ScalarField))

def test_vectorfield_dot_product(self):
r = Run(diag_outputs)
r = Run(self.diag_dir())
time = 0.0
B = r.GetB(time)
s1 = dot(B, B)
Expand All @@ -306,7 +307,7 @@ def test_vectorfield_dot_product(self):
self.assertEqual(s.quantities(), ["value"])

def test_vectorfield_binary_ops(self):
r = Run(diag_outputs)
r = Run(self.diag_dir())
time = 0.0
B = r.GetB(time)
V = r.GetVi(time)
Expand All @@ -321,7 +322,7 @@ def test_vectorfield_binary_ops(self):
self.assertEqual(s.quantities(), ["x", "y", "z"])

def test_scalarfield_to_vectorfield_ops(self):
r = Run(diag_outputs)
r = Run(self.diag_dir())
time = 0.0
Ni = r.GetNi(time)
s1 = grad(Ni)
Expand All @@ -330,7 +331,7 @@ def test_scalarfield_to_vectorfield_ops(self):
self.assertEqual(s.quantities(), ["x", "y", "z"])

def test_vectorfield_to_vectorfield_ops(self):
r = Run(diag_outputs)
r = Run(self.diag_dir())
time = 0.0
B = r.GetB(time)
E = r.GetE(time)
Expand Down

0 comments on commit 1eff256

Please sign in to comment.