def test_real_apply(comm): pm = ParticleMesh(BoxSize=8.0, Nmesh=[8, 8], comm=comm, dtype='f8') real = RealField(pm) def filter(x, v): return x[0] * 10 + x[1] real.apply(filter, out=Ellipsis) for i, x, slab in zip(real.slabs.i, real.slabs.x, real.slabs): assert_array_equal(slab, x[0] * 10 + x[1])
def test_real_apply(comm): pm = ParticleMesh(BoxSize=8.0, Nmesh=[8, 8], comm=comm, dtype='f8') real = RealField(pm) def filter(x, v): xnormp = x.normp() assert_allclose(xnormp, sum(xi ** 2 for xi in x)) return x[0] * 10 + x[1] real.apply(filter, out=Ellipsis) for i, x, slab in zip(real.slabs.i, real.slabs.x, real.slabs): assert_array_equal(slab, x[0] * 10 + x[1])