Skip to content

Commit e61b34c

Browse files
authored
Merge pull request #919 from PhilipDeegan/pyattrs
keep pyattrs on compute_from_hier
2 parents 52e733e + 2558d44 commit e61b34c

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

pyphare/pyphare/pharesee/hierarchy/hierarchy_utils.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,16 @@ def new_patchdatas_from(compute, patchdatas, layout, id, **kwargs):
192192
def new_patches_from(compute, hierarchies, ilvl, t, **kwargs):
193193
reference_hier = hierarchies[0]
194194
new_patches = []
195-
patch_nbr = len(reference_hier.level(ilvl, time=t).patches)
196-
for ip in range(patch_nbr):
197-
current_patch = reference_hier.level(ilvl, time=t).patches[ip]
195+
ref_patches = reference_hier.level(ilvl, time=t).patches
196+
for ip, current_patch in enumerate(ref_patches):
198197
layout = current_patch.layout
199198
patch_datas = extract_patchdatas(hierarchies, ilvl, t, ip)
200199
new_patch_datas = new_patchdatas_from(
201200
compute, patch_datas, layout, id=current_patch.id, **kwargs
202201
)
203-
new_patches.append(Patch(new_patch_datas, current_patch.id))
202+
new_patches.append(
203+
Patch(new_patch_datas, current_patch.id, attrs=current_patch.attrs)
204+
)
204205
return new_patches
205206

206207

tests/simulator/test_run.py

+17-11
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
#!/usr/bin/env python3
22

3+
import numpy as np
34
from pathlib import Path
5+
import matplotlib as mpl
46

57
import pyphare.pharein as ph
8+
from pyphare.cpp import cpp_lib
69
from pyphare.simulator.simulator import Simulator, startMPI
710
from pyphare.pharesee.run import Run
8-
9-
import numpy as np
10-
11-
import matplotlib as mpl
12-
13-
mpl.use("Agg")
14-
15-
from pyphare.cpp import cpp_lib
1611
from tests.simulator import SimulatorTest
1712

13+
mpl.use("Agg")
1814

1915
cpp = cpp_lib()
2016
startMPI()
2117

2218
time_step = 0.005
23-
final_time = 0.1
19+
final_time = 0.05
2420
time_step_nbr = int(final_time / time_step)
2521
timestamps = np.arange(0, final_time + 0.01, 0.05)
2622
diag_dir = "phare_outputs/test_run"
@@ -224,15 +220,25 @@ def test_run(self):
224220
sim = config()
225221
self.register_diag_dir_for_cleanup(diag_dir)
226222
Simulator(sim).run().reset()
223+
224+
run = Run(diag_dir)
225+
B = run.GetB(timestamps[-1], all_primal=False)
226+
self.assertTrue(B.levels()[0].patches[0].attrs)
227+
228+
B = run.GetB(timestamps[-1])
229+
self.assertTrue(B.levels()[0].patches[0].attrs)
230+
227231
if cpp.mpi_rank() == 0:
228232
plot(diag_dir)
229233

230234
for time in timestamps:
231235
for q in ["divb", "Ranks", "N", "jz"]:
232236
assert_file_exists_with_size_at_least(plot_file_for_qty(q, time))
233-
237+
234238
for c in ["x", "y", "z"]:
235-
assert_file_exists_with_size_at_least(plot_file_for_qty(f"b{c}", time))
239+
assert_file_exists_with_size_at_least(
240+
plot_file_for_qty(f"b{c}", time)
241+
)
236242

237243
cpp.mpi_barrier()
238244

0 commit comments

Comments
 (0)