From 6381b8cfccd344e220e1e9098d6476f888aae0d6 Mon Sep 17 00:00:00 2001 From: Philipp Holl Date: Wed, 8 Jan 2025 14:33:32 +0100 Subject: [PATCH] [field] Fix Field.bounds, make sliceable --- phi/field/_field.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/phi/field/_field.py b/phi/field/_field.py index c956324f9..7b7880308 100644 --- a/phi/field/_field.py +++ b/phi/field/_field.py @@ -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 @@ -45,6 +46,7 @@ def __call__(cls, return result +@sliceable @dataclass(frozen=True) class Field(metaclass=_FieldType): """ @@ -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 @@ -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.