Skip to content

Commit

Permalink
[field] Fix resampling via with_values()
Browse files Browse the repository at this point in the history
  • Loading branch information
holl- committed Jan 30, 2024
1 parent 119b6a8 commit 62dcd87
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion phi/field/_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,11 @@ def closest_values(self, points: Tensor):
channels = [component.closest_values(points) for component in self.vector.unstack()]
return math.stack(channels, points.shape['~vector'])

def with_values(self, values):
def with_values(self, values, **sampling_kwargs):
""" Returns a copy of this field with `values` replaced. """
if not isinstance(values, Tensor):
from ._resample import sample
values = sample(values, self._geometry, self.sampled_at, self._boundary, **sampling_kwargs)
return Field(self._geometry, values, self._boundary)

def with_boundary(self, boundary):
Expand Down

0 comments on commit 62dcd87

Please sign in to comment.