Skip to content

Commit

Permalink
Merge pull request #1730 from fzahle/numpy_funcs_execcomp
Browse files Browse the repository at this point in the history
add support for numpy min, max and diff in ExecComp
  • Loading branch information
swryan committed Oct 13, 2020
2 parents 15c942e + 13e546a commit 244b4ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion openmdao/components/exec_comp.py
Expand Up @@ -627,7 +627,7 @@ def _import_functs(mod, dct, names=None):
'e', 'pi', # Constants
'isinf', 'isnan', # Logic
'log', 'log10', 'log1p', 'power', # Math operations
'exp', 'expm1', 'fmax',
'exp', 'expm1', 'fmax', 'min', 'max', 'diff',
'fmin', 'maximum', 'minimum',
'sum', 'dot', 'prod', # Reductions
'tensordot', 'matmul', # Linear algebra
Expand Down
15 changes: 15 additions & 0 deletions openmdao/components/tests/test_exec_comp.py
Expand Up @@ -18,6 +18,21 @@
from openmdao.utils.assert_utils import assert_near_equal, assert_check_partials, assert_warning

_ufunc_test_data = {
'min': {
'str': 'f=min(x)',
'check_func': np.min,
'args': { 'f': {'value': np.zeros(6)},
'x': {'value': np.random.random(6)}}},
'max': {
'str': 'f=max(x)',
'check_func': np.max,
'args': { 'f': {'value': np.zeros(6)},
'x': {'value': np.random.random(6)}}},
'diff': {
'str': 'f=diff(x)',
'check_func': np.diff,
'args': { 'f': {'value': np.zeros(5)},
'x': {'value': np.random.random(6)}}},
'abs': {
'str': 'f=abs(x)',
'check_func': np.abs,
Expand Down

0 comments on commit 244b4ee

Please sign in to comment.