def test_downsample_staggered_2d(self): grid = StaggeredGrid(1, extrapolation.BOUNDARY, x=32, y=40) downsampled = field.downsample2x(grid) self.assertEqual(set(spatial(x=16, y=20) & channel(vector=2)), set(downsampled.shape))
def test_downsample_staggered_2d(self): grid = Domain(x=32, y=40).staggered_grid(1) downsampled = field.downsample2x(grid) self.assertEqual( math.shape(x=16, y=20, vector=2).alphabetically(), downsampled.shape.alphabetically())
def test_upsample_downsample_centered_1d(self): grid = CenteredGrid(math.tensor([0, 1, 2, 3], spatial('x'))) upsampled = field.upsample2x(grid) downsampled = field.downsample2x(upsampled) math.assert_close(downsampled.values.x[1:-1], grid.values.x[1:-1])
def test_upsample_downsample_centered_1d(self): grid = Domain(x=4).scalar_grid([0, 1, 2, 3]) upsampled = field.upsample2x(grid) downsampled = field.downsample2x(upsampled) math.assert_close(downsampled.values.x[1:-1], grid.values.x[1:-1])