Skip to content

Commit

Permalink
Fix J_fwd vs J_rev problem in OpenMDAO.jl tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dingraha committed Feb 20, 2024
1 parent 268b310 commit 9be6776
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions julia/OpenMDAO.jl/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1044,9 +1044,26 @@ end
for (pyvar, pywrt) in keys(ctd)
var = pyconvert(Any, pyvar)
wrt = pyconvert(Any, pywrt)
J_fwd = pyconvert(Dict, ctd[var, wrt])["J_fwd"]
# In OpenMDAO 3.26.0, the correct key is always `"J_fwd"`, but in 3.30.0 it depends on the `mode` argument to `problem.setup()`.
try
J_actual = pyconvert(Dict, ctd[var, wrt])["J_fwd"]
catch e1
if isa(e1, KeyError)
try
J_actual = pyconvert(Dict, ctd[var, wrt])["J_rev"]
catch e2
if isa(e2, KeyError)
throw(KeyError("ctd[$(var), $(wrt)] contains neither \"J_fwd\" nor \"J_rev\""))
else
rethrow(e2)
end
end
else
rethrow(e1)
end
end
J_fd = pyconvert(Dict, ctd[var, wrt])["J_fd"]
@test J_fwd J_fd
@test J_actual J_fd
end
end

Expand Down

0 comments on commit 9be6776

Please sign in to comment.