Skip to content

Commit

Permalink
[field] Fix Field.bounds, make sliceable
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Holl committed Jan 8, 2025
1 parent c71166b commit 6381b8c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions phi/field/_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from phi.math import Shape, Tensor, channel, non_batch, expand, instance, spatial, wrap, dual, non_dual
from phi.math.extrapolation import Extrapolation
from phi.math.magic import BoundDim, slicing_dict
from phiml.dataclasses import sliceable
from phiml.math import batch, Solve, DimFilter, unstack, concat_shapes, pack_dims, shape
from phiml.math.extrapolation import domain_slice

Expand Down Expand Up @@ -45,6 +46,7 @@ def __call__(cls,
return result


@sliceable
@dataclass(frozen=True)
class Field(metaclass=_FieldType):
"""
Expand Down Expand Up @@ -232,7 +234,7 @@ def bounds(self) -> BaseBox:
Fields whose spatial rank is determined only during sampling return an empty `Box`.
"""
if isinstance(self.geometry.bounds, BaseBox):
if hasattr(self.geometry, 'bounds') and isinstance(self.geometry.bounds, BaseBox):
return self.geometry.bounds
extent = self.geometry.bounding_half_extent().vector.as_dual('_extent')
points = self.geometry.center + extent
Expand Down Expand Up @@ -682,9 +684,6 @@ def __getitem__(self, item) -> 'Field':
values = self.values[item]
return Field(geometry, values, boundary)

def __getattr__(self, name: str) -> BoundDim:
return BoundDim(self, name)

def dimension(self, name: str):
"""
Returns a reference to one of the dimensions of this field.
Expand Down

0 comments on commit 6381b8c

Please sign in to comment.