Skip to content

Commit b70610e

Browse files
committed
make copy of data
lint
1 parent 59a79da commit b70610e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

firedrake/function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ def evaluate(self, function: Function) -> np.ndarray | Tuple[np.ndarray, ...]:
812812
f_at_points = assemble(interpolate(function, P0DG))
813813
f_at_points_io = Function(P0DG_io).assign(np.nan)
814814
f_at_points_io.interpolate(f_at_points)
815-
result = f_at_points_io.dat.data_ro
815+
result = f_at_points_io.dat.data_ro.copy()
816816

817817
# If redundant, all points are now on rank 0, so we broadcast the result
818818
if self.redundant and self.mesh.comm.size > 1:

tests/firedrake/regression/test_point_eval_api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ def test_point_evaluator_scalar(mesh_and_points):
194194
f_at_points_missing = eval_missing.evaluate(f)
195195
assert np.isnan(f_at_points_missing[-1])
196196

197+
# Can modify result
198+
f_at_points *= 2.0
199+
assert np.allclose(f_at_points, [0.4, 0.8, 1.2])
200+
197201

198202
@pytest.mark.parallel([1, 3])
199203
def test_point_evaluator_vector_tensor_mixed(mesh_and_points):

0 commit comments

Comments
 (0)