Skip to content

Commit

Permalink
[field] Add Field.pad()
Browse files Browse the repository at this point in the history
  • Loading branch information
holl- committed Dec 10, 2023
1 parent 0ac7345 commit 6205ab9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions phi/field/_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,24 @@ def with_geometry(self, elements: Geometry):
def shifted(self, delta):
return self.with_elements(self._geometry.shifted(delta))

def pad(self, widths: Union[int, tuple, list, dict]) -> 'Field':
"""
Alias for `phi.field.pad()`.
Pads this `Field` using its extrapolation.
Unlike padding the values, this function also affects the `geometry` of the field, changing its size and origin depending on `widths`.
Args:
widths: Either `int` or `(lower, upper)` to pad the same number of cells in all spatial dimensions
or `dict` mapping dimension names to `(lower, upper)`.
Returns:
Padded `Field`
"""
from ._field_math import pad
return pad(self, widths)

def staggered_tensor(self) -> Tensor:
"""
Stacks all component grids into a single uniform `phi.math.Tensor`.
Expand Down

0 comments on commit 6205ab9

Please sign in to comment.