From 92f06b8c4ff2b79dac05e82f19fc6c8d35b14680 Mon Sep 17 00:00:00 2001 From: Philipp Holl Date: Tue, 16 Apr 2024 13:04:14 +0200 Subject: [PATCH] [geom] Fix Graph.shifted/at --- phi/geom/_graph.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/phi/geom/_graph.py b/phi/geom/_graph.py index a7d62b27e..ce9839fba 100644 --- a/phi/geom/_graph.py +++ b/phi/geom/_graph.py @@ -137,7 +137,14 @@ def bounding_half_extent(self) -> Tensor: return self._nodes.bounding_half_extent() def at(self, center: Tensor) -> 'Geometry': - return Graph(self.nodes.at(center), self._edges, self._boundary) + raise NotImplementedError("Changing the node positions of a Graph is not supported as it would invalidate distances.") + # warnings.warn("Changing the node positions of a graph triggers re-evaluation of distances.", RuntimeWarning, stacklevel=2) + # return Graph(self.nodes.at(center), self._edges, self._boundary, bounding_distance=self._bounding_distance is not None) + + def shifted(self, delta: Tensor) -> 'Geometry': + if non_batch(delta).non_channel.only(self._nodes.shape): # shift varies between + raise NotImplementedError("Shifting the node positions of a Graph is not supported as it would invalidate distances.") + return Graph(self.nodes.shifted(delta), self._edges, self._boundary, deltas=self._deltas, distances=self._distances, bounding_distance=self._bounding_distance is not None) def rotated(self, angle: Union[float, Tensor]) -> 'Geometry': raise NotImplementedError