Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for numpy min, max and diff in ExecComp #1730

Merged
merged 1 commit into from Oct 13, 2020

Conversation

fzahle
Copy link
Contributor

@fzahle fzahle commented Oct 7, 2020

Summary

Summary of PR.

Related Issues

  • Resolves #

Backwards incompatibilities

None

New Dependencies

None

@project-bot project-bot bot added this to In progress in OpenMDAO Dev [Read only] Oct 7, 2020
OpenMDAO Dev [Read only] automation moved this from In progress to Reviewer approved Oct 7, 2020
@fzahle
Copy link
Contributor Author

fzahle commented Oct 7, 2020

we also use np.interp here and there, but adding this is more tricky since it doesn't pass the complex step test. Looking at using the SplineComp instead.

@JustinSGray
Copy link
Member

JustinSGray commented Oct 7, 2020

wait ... min and max are not differentiable .... hrm....

I guess we had fmax in there, as well as maximum and minumum already. None of those are differentiable... Im not even sure how they behave when use complex step with them...

I guess I can't object to new non-differentiable functions being added when there are already some in there, though it does make me a bit nervous

@fzahle
Copy link
Contributor Author

fzahle commented Oct 7, 2020

if you use complex step for derivatives, it should work since it will find the min/max along the real axis and return that along with the corresponding complex part.

@JustinSGray
Copy link
Member

That is only mathematically valid if the location of the max-value in the array isn't changing. Will it work? probably for fairly well behaved functions. Anyway, its there now... so I guess we're stuck with it. So I can't object to adding the similar methods either.

import numpy as np 

a = np.ones(4)*10

b = np.ones(4, dtype='complex')*10
b[0] += complex(0, 1e-50)

print(np.max(a))

print(np.max(b))

b[1] += 1e-10
print(np.max(b))

@robfalck robfalck self-requested a review October 13, 2020 16:21
@project-bot project-bot bot moved this from Reviewer approved to Under review in OpenMDAO Dev [Read only] Oct 13, 2020
OpenMDAO Dev [Read only] automation moved this from Under review to Reviewer approved Oct 13, 2020
@swryan swryan merged commit 244b4ee into OpenMDAO:master Oct 13, 2020
OpenMDAO Dev [Read only] automation moved this from Reviewer approved to Done Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants