MCPcopy
hub / github.com/tum-pbs/PhiFlow / test_reshaping

Method test_reshaping

tests/commit/geom/test__sphere.py:45–54  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

43 self.assertEqual(Sphere(x=4, radius=1), sphere['x'])
44
45 def test_reshaping(self):
46 s = stack([Sphere(vec(x=0, y=0), radius=1)] * 50, instance('points'))
47 s = expand(s, batch(b=100))
48 s = rename_dims(s, 'b', 'bat')
49 s = unpack_dim(s, 'points', spatial(x=10, y=5))
50 assert batch(bat=100) & spatial(x=10, y=5) & channel(vector='x,y') == s.shape
51 s = pack_dims(s, 'x,y', instance('particles'))
52 assert batch(bat=100) & instance(particles=50) & channel(vector='x,y') == s.shape
53 s = flatten(s)
54 assert batch(bat=100) & instance(flat=50) & channel(vector='x,y') == s.shape
55
56 def test_reshaping_const_radius(self):
57 s = Sphere(stack([vec(x=0, y=0)] * 50, instance('points')), radius=1)

Callers

nothing calls this directly

Calls 3

stackFunction · 0.90
SphereClass · 0.90
pack_dimsFunction · 0.90

Tested by

no test coverage detected