Skip to content

Commit

Permalink
Revert "[field] Fix with_values(number) for staggered"
Browse files Browse the repository at this point in the history
This reverts commit 9ac7b96.
  • Loading branch information
holl- committed May 19, 2024
1 parent 96bc595 commit 57b5c72
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 16 deletions.
8 changes: 0 additions & 8 deletions phi/field/_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,6 @@ def with_values(self, values, **sampling_kwargs):
if not isinstance(values, (Tensor, Number)):
from ._resample import sample
values = sample(values, self._geometry, self.sampled_at, self._boundary, dot_face_normal=self._geometry if 'vector' not in self._values.shape else None, **sampling_kwargs)
else:
if self.is_staggered and not spatial(values):
geo_shape = self.sampled_elements.shape # this is slow
# geo_shape = self._geometry.face_shape
# slice_off_constant_faces(geo_shape, self._geometry.boundary_faces, self._boundary)
else:
geo_shape = self._geometry.shape
values = expand(wrap(values), geo_shape.non_batch.non_channel)
return Field(self._geometry, values, self._boundary)

def with_boundary(self, boundary):
Expand Down
8 changes: 0 additions & 8 deletions tests/commit/field/test__grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,3 @@ def test_reshape_staggered_grid(self):
grid = math.expand(StaggeredGrid(1, x=10, y=10), batch(b=100))
grid = math.rename_dims(grid, 'b', 'bat')
self.assertEqual(batch(bat=100) & spatial(x=10, y=10) & channel(vector='x,y'), grid.shape)

def test_with_values_staggered(self):
grid = StaggeredGrid(Noise(), 1, x=10, y=10)
grid0 = grid.with_values(0)
self.assertEqual({'x', 'y', '~vector'}, set(grid0.values.shape.names))
cgrid = grid.with_values(math.zeros(spatial(x=10, y=10)))
self.assertEqual({'x', 'y'}, set(cgrid.values.shape.names))

0 comments on commit 57b5c72

Please sign in to comment.