Skip to content

Commit 7e0583a

Browse files
committed
Tests & Internal: Modernize API
Avoid using the deprecated APIs.
1 parent cd83f00 commit 7e0583a

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/amrex/extensions/ParticleContainer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def pc_to_df(self, local=True, comm=None, root_rank=0):
103103
# local DataFrame(s)
104104
dfs_local = []
105105
for lvl in range(self.finest_level + 1):
106-
for pti in self.const_iterator(self, level=lvl):
106+
for pti in self.const_iterator(level=lvl):
107107
if pti.size == 0:
108108
continue
109109

tests/test_particleContainer.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def particle_container(Npart, std_geometry, distmap, boxarr, std_real_box):
6363

6464
# assign some values to runtime components
6565
for lvl in range(pc.finest_level + 1):
66-
for pti in pc.iterator(pc, level=lvl):
66+
for pti in pc.iterator(level=lvl):
6767
soa = pti.soa()
6868
soa.get_real_data(2).assign(1.2345)
6969
soa.get_int_data(1).assign(42)
@@ -97,7 +97,7 @@ def soa_particle_container(Npart, std_geometry, distmap, boxarr, std_real_box):
9797

9898
# assign some values to runtime components
9999
for lvl in range(pc.finest_level + 1):
100-
for pti in pc.iterator(pc, level=lvl):
100+
for pti in pc.iterator(level=lvl):
101101
soa = pti.soa()
102102
soa.get_real_data(8).assign(1.2345)
103103
soa.get_int_data(0).assign(42)
@@ -212,7 +212,7 @@ def test_pc_init():
212212
# lvl = 0
213213
for lvl in range(pc.finest_level + 1):
214214
print(f"at level {lvl}:")
215-
for pti in pc.iterator(pc, level=lvl):
215+
for pti in pc.iterator(level=lvl):
216216
print("...")
217217
assert pti.num_particles == 1
218218
assert pti.num_real_particles == 1
@@ -243,7 +243,7 @@ def test_pc_init():
243243

244244
# read-only
245245
for lvl in range(pc.finest_level + 1):
246-
for pti in pc.const_iterator(pc, level=lvl):
246+
for pti in pc.const_iterator(level=lvl):
247247
assert pti.num_particles == 1
248248
assert pti.num_real_particles == 1
249249
assert pti.num_neighbor_particles == 0
@@ -383,7 +383,7 @@ class Config:
383383
# iterate over mesh-refinement levels
384384
for lvl in range(pc.finest_level + 1):
385385
# loop local tiles of particles
386-
for pti in pc.iterator(pc, level=lvl):
386+
for pti in pc.iterator(level=lvl):
387387
# compile-time and runtime attributes
388388
soa = pti.soa().to_xp()
389389

@@ -420,8 +420,8 @@ class Config:
420420
# print all particle ids in the tile
421421
print("idcpu =", pti["idcpu"])
422422

423-
x = pti["x"]
424-
y = pti["y"]
423+
x = pti["x"] # this is automatically a cupy or numpy
424+
y = pti["y"] # array, depending on Config.have_gpu
425425

426426
# write to all particles in the chunk
427427
# note: careful, if you change particle positions, you might need to
@@ -457,7 +457,7 @@ class Config:
457457
# iterate over mesh-refinement levels
458458
for lvl in range(pc.finest_level + 1):
459459
# loop local tiles of particles
460-
for pti in pc.iterator(pc, level=lvl):
460+
for pti in pc.iterator(level=lvl):
461461
# default layout: AoS with positions and idcpu
462462
# note: not part of the new PureSoA particle container layout
463463
aos = (

tests/test_plotfileparticledata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def particle_container(Rpart, std_geometry, distmap, boxarr, std_real_box):
6565
particles_tile_ct = 0
6666
# assign some values to runtime components
6767
for lvl in range(pc.finest_level + 1):
68-
for pti in pc.iterator(pc, level=lvl):
68+
for pti in pc.iterator(level=lvl):
6969
aos = pti.aos()
7070
aos_numpy = aos.to_numpy(copy=False)
7171
for i, p in enumerate(aos_numpy):
@@ -81,7 +81,7 @@ def check_particles_container(pc, reference_particles):
8181
Checks the contents of `pc` against `reference_particles`
8282
"""
8383
for lvl in range(pc.finest_level + 1):
84-
for i, pti in enumerate(pc.iterator(pc, level=lvl)):
84+
for i, pti in enumerate(pc.iterator(level=lvl)):
8585
aos = pti.aos()
8686
for p in aos.to_numpy(copy=True):
8787
ref = reference_particles[p["idata_0"]]

0 commit comments

Comments
 (0)