Skip to content

Commit 2561ddc

Browse files
committed
Compatibility with latest tlm_adjoint: Update methods to properties
1 parent 758f5e4 commit 2561ddc

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

fenics_ice/minimize_l_bfgs.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ def F(*X, force=False):
11001100
function_axpy(change, -1.0, last_m)
11011101
change_norm = max(change_norm, function_linf_norm(change))
11021102
if change_norm == 0.0:
1103-
return last_F[2].value()
1103+
return last_F[2].value
11041104

11051105
last_F[0] = functions_copy(X)
11061106
functions_assign(M, X)
@@ -1116,12 +1116,12 @@ def F(*X, force=False):
11161116
last_F[2] = forward(last_F[1])
11171117
manager.stop()
11181118

1119-
return last_F[2].value()
1119+
return last_F[2].value
11201120

11211121
def Fp(*X):
11221122
F(*X, force=last_F[1] is None)
11231123
dJ = manager.compute_gradient(last_F[2], last_F[1])
1124-
if manager._cp_schedule.is_exhausted():
1124+
if manager._cp_schedule.is_exhausted:
11251125
last_F[1] = None
11261126
return dJ
11271127

fenics_ice/solver.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ def inversion(self):
878878
##########################################
879879
# dJ = compute_gradient(J, self.alpha)
880880
# ddJ = Hessian(forward)
881-
# min_order = taylor_test(forward, self.alpha, J_val=J.value(),
881+
# min_order = taylor_test(forward, self.alpha, J_val=J.value,
882882
# dJ=dJ, ddJ=ddJ, seed=1.0e-6)
883883

884884
def l_bfgs_converged(it, old_J_val, new_J_val,
@@ -1309,36 +1309,36 @@ def comp_J_inv(self, verbose=False):
13091309
u_PRP, v_PRP, l_u_obs, l_v_obs, J_u_obs, J_v_obs) = \
13101310
self._cached_J_mismatch_data
13111311

1312-
J_ls_term_u = Functional(name="J_term_u", space=J.space())
1313-
J_ls_term_v = Functional(name="J_term_v", space=J.space())
1312+
J_ls_term_u = Functional(name="J_term_u", space=J.space)
1313+
J_ls_term_v = Functional(name="J_term_v", space=J.space)
13141314

13151315
# .5 * u^T P^T R_u_obs^{-1} P u
1316-
J_term = space_new(J.space())
1316+
J_term = space_new(J.space)
13171317
InnerProduct(J_term, uf, uf, M=u_PRP, alpha = fac).solve()
13181318
J_ls_term_u.addto(J_term)
13191319

13201320
# .5 * v^T P^T R_v_obs^{-1} P v
1321-
J_term = space_new(J.space())
1321+
J_term = space_new(J.space)
13221322
InnerProduct(J_term, vf, vf, M=v_PRP, alpha = fac).solve()
13231323
J_ls_term_v.addto(J_term)
13241324

13251325
# -.5 * 2 * u_obs^T R_u_obs^{-1} P u
1326-
J_term = space_new(J.space())
1326+
J_term = space_new(J.space)
13271327
InnerProduct(J_term, uf, l_u_obs, alpha=-2.0 * fac).solve()
13281328
J_ls_term_u.addto(J_term)
13291329

13301330
# -.5 * 2 * v_obs^T R_v_obs^{-1} P v
1331-
J_term = space_new(J.space())
1331+
J_term = space_new(J.space)
13321332
InnerProduct(J_term, vf, l_v_obs, alpha=-2.0 * fac).solve()
13331333
J_ls_term_v.addto(J_term)
13341334

13351335
# .5 * u_obs R_u_obs^{-1} u_obs
1336-
J_term = space_new(J.space())
1336+
J_term = space_new(J.space)
13371337
function_assign(J_term, fac * J_u_obs)
13381338
J_ls_term_u.addto(J_term)
13391339

13401340
# .5 * v_obs R_v_obs^{-1} v_obs
1341-
J_term = space_new(J.space())
1341+
J_term = space_new(J.space)
13421342
function_assign(J_term, fac * J_v_obs)
13431343
J_ls_term_v.addto(J_term)
13441344

@@ -1375,7 +1375,7 @@ def comp_J_inv(self, verbose=False):
13751375

13761376
if verbose:
13771377
# Print out results
1378-
J1 = J.value()
1378+
J1 = J.value
13791379
J2 = (function_scalar_value(J_ls_term_u)
13801380
+ function_scalar_value(J_ls_term_v))
13811381

runs/run_taylor_fwd_inv.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def forward_ts(cntrl, cntrl_init, name):
8484
cntrl_curr_init,
8585
cntrl_curr.name()),
8686
cntrl_curr,
87-
J_val=J.value(),
87+
J_val=J.value,
8888
dJ=dJ_curr,
8989
seed=seeds[cntrl_curr.name()],
9090
M0=cntrl_curr_init,

tests/test_runs.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_run_inversion(persistent_temp_model, monkeypatch):
5757
cntrl = mdl_out.solvers[0].get_control()[0]
5858
cntrl_norm = norm(cntrl.vector())
5959

60-
J_inv = mdl_out.solvers[0].J_inv.value()
60+
J_inv = mdl_out.solvers[0].J_inv.value
6161

6262
pytest.check_float_result(cntrl_norm,
6363
expected_cntrl_norm,
@@ -220,7 +220,7 @@ def forward_ts(cntrl, cntrl_init, name):
220220
cntrl_curr_init,
221221
cntrl_curr.name()),
222222
cntrl_curr,
223-
J_val=J.value(),
223+
J_val=J.value,
224224
dJ=dJ_curr,
225225
seed=seeds[cntrl_curr.name()],
226226
M0=cntrl_curr_init,
@@ -356,7 +356,7 @@ def test_run_smith_inversion(temp_model, monkeypatch):
356356
mdl_out = run_inv.run_inv(toml_file)
357357

358358
# Test inversion value
359-
J_inv = mdl_out.solvers[0].J_inv.value()
359+
J_inv = mdl_out.solvers[0].J_inv.value
360360

361361
pytest.check_float_result(J_inv,
362362
expected_J_inv,

0 commit comments

Comments
 (0)