Skip to content

Commit

Permalink
Merge pull request #47 from swryan/om331
Browse files Browse the repository at this point in the history
Fixed test for change of jacobian keys in OpenMDAO 3.31
  • Loading branch information
swryan authored Mar 7, 2024
2 parents 0504334 + 05744a8 commit f1f5b00
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CADRE_test_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ jobs:
- name: Setup conda
uses: conda-incubator/setup-miniconda@v2
with:
python-version: 3
python-version: 3.11
conda-version: "*"
channels: conda-forge,defaults
channel-priority: true

- name: Create Environment
run: |
conda install numpy scipy -q -y
conda install numpy=1.23 scipy -q -y
python -m pip install --upgrade pip
Expand Down
13 changes: 12 additions & 1 deletion CADRE/test/test_mdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
import pickle
import unittest

from packaging.version import Version

import numpy as np

from openmdao import __version__ as om_version
from openmdao.api import Problem, PETScKrylov
from openmdao.utils.mpi import MPI

Expand Down Expand Up @@ -161,7 +164,15 @@ def test_CADRE_MDP(self):
bkey2 = '.'.join(parts)

actual = Ja[key1][key2]
computed = Jb[bkey1, bkey2]
if Version(om_version) <= Version("3.30"):
computed = Jb[bkey1, bkey2]
else:
# as of OpenMDAO 3.31.0, the keys in the jac are the 'user facing' names
# given to the design vars and responses, rather than the absolute names
# that were used previously
computed = Jb[prob.model._var_allprocs_abs2prom['output'][bkey1],
prob.model._var_allprocs_abs2prom['output'][bkey2]]

if isinstance(computed, np.ndarray):
rel = np.linalg.norm(actual - computed)/np.linalg.norm(actual)
else:
Expand Down

0 comments on commit f1f5b00

Please sign in to comment.