Skip to content

Commit b42175c

Browse files
committed
no annotation for adj_sol buffer creation, and test warning fixes
1 parent 0541ade commit b42175c

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

firedrake/adjoint_utils/blocks/solving.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def __init__(self, lhs, rhs, func, bcs, *args, **kwargs):
5656
# Solution function
5757
self.func = func
5858
self.function_space = self.func.function_space()
59-
self.adj_state_buf = self.func.copy(deepcopy=True)
59+
self.adj_state_buf = self.func.copy(deepcopy=True, annotate=False)
6060
# Boundary conditions
6161
self.bcs = []
6262
if bcs is not None:

tests/firedrake/regression/test_adjoint_operators.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def test_interpolate_vector_valued():
124124
J = assemble(inner(f, g)*u**2*dx)
125125
rf = ReducedFunctional(J, Control(f))
126126

127-
h = Function(V1).assign(1)
127+
h = Function(V1).assign(1.)
128128
assert taylor_test(rf, f, h) > 1.9
129129

130130

@@ -144,7 +144,7 @@ def test_interpolate_tlm():
144144
J = assemble(inner(f, g)*u**2*dx)
145145
rf = ReducedFunctional(J, Control(f))
146146

147-
h = Function(V1).assign(1)
147+
h = Function(V1).assign(1.)
148148
f.block_variable.tlm_value = h
149149

150150
tape = get_working_tape()
@@ -259,7 +259,7 @@ def test_interpolate_to_function_space_cross_mesh():
259259
mesh_src = UnitSquareMesh(2, 2)
260260
mesh_dest = UnitSquareMesh(3, 3, quadrilateral=True)
261261
V = FunctionSpace(mesh_src, "CG", 1)
262-
W = FunctionSpace(mesh_dest, "DG", 1)
262+
W = FunctionSpace(mesh_dest, "DQ", 1)
263263
R = FunctionSpace(mesh_src, "R", 0)
264264
u = Function(V)
265265

@@ -290,7 +290,7 @@ def test_interpolate_hessian_linear_expr(rg):
290290
# space h and perterbation direction g.
291291
W = FunctionSpace(mesh, "Lagrange", 2)
292292
R = FunctionSpace(mesh, "R", 0)
293-
f = Function(W).assign(5)
293+
f = Function(W).assign(5.)
294294
# Note that we interpolate from a linear expression
295295
expr_interped = Function(V).interpolate(2*f)
296296

@@ -345,7 +345,7 @@ def test_interpolate_hessian_nonlinear_expr(rg):
345345
# space h and perterbation direction g.
346346
W = FunctionSpace(mesh, "Lagrange", 2)
347347
R = FunctionSpace(mesh, "R", 0)
348-
f = Function(W).assign(5)
348+
f = Function(W).assign(5.)
349349
# Note that we interpolate from a nonlinear expression
350350
expr_interped = Function(V).interpolate(f**2)
351351

@@ -400,8 +400,8 @@ def test_interpolate_hessian_nonlinear_expr_multi(rg):
400400
# space h and perterbation direction g.
401401
W = FunctionSpace(mesh, "Lagrange", 2)
402402
R = FunctionSpace(mesh, "R", 0)
403-
f = Function(W).assign(5)
404-
w = Function(W).assign(4)
403+
f = Function(W).assign(5.)
404+
w = Function(W).assign(4.)
405405
c = Function(R, val=2.0)
406406
# Note that we interpolate from a nonlinear expression with 3 coefficients
407407
expr_interped = Function(V).interpolate(f**2+w**2+c**2)
@@ -460,8 +460,8 @@ def test_interpolate_hessian_nonlinear_expr_multi_cross_mesh(rg):
460460
mesh_src = UnitSquareMesh(11, 11)
461461
R_src = FunctionSpace(mesh_src, "R", 0)
462462
W = FunctionSpace(mesh_src, "Lagrange", 2)
463-
f = Function(W).assign(5)
464-
w = Function(W).assign(4)
463+
f = Function(W).assign(5.)
464+
w = Function(W).assign(4.)
465465
c = Function(R_src, val=2.0)
466466
# Note that we interpolate from a nonlinear expression with 3 coefficients
467467
expr_interped = Function(V).interpolate(f**2+w**2+c**2)
@@ -1035,8 +1035,9 @@ def u_analytical(x, a, b):
10351035
tape = get_working_tape()
10361036
# Check the checkpointed boundary conditions are not updating the
10371037
# user-defined boundary conditions ``bc_left`` and ``bc_right``.
1038-
assert isinstance(tape._blocks[0], DirichletBCBlock) and \
1039-
tape._blocks[0]._outputs[0].checkpoint.checkpoint is not bc_left._original_arg
1038+
assert isinstance(tape._blocks[0], DirichletBCBlock)
1039+
assert tape._blocks[0]._outputs[0].checkpoint.checkpoint is not bc_left._original_arg
1040+
10401041
# tape._blocks[1] is the DirichletBC block for the right boundary
1041-
assert isinstance(tape._blocks[1], DirichletBCBlock) and \
1042-
tape._blocks[1]._outputs[0].checkpoint.checkpoint is not bc_right._original_arg
1042+
assert isinstance(tape._blocks[1], DirichletBCBlock)
1043+
assert tape._blocks[1]._outputs[0].checkpoint.checkpoint is not bc_right._original_arg

0 commit comments

Comments
 (0)