-
Notifications
You must be signed in to change notification settings - Fork 234
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
FD for composite staggered expr #1247
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1247 +/- ##
==========================================
+ Coverage 86.16% 86.23% +0.06%
==========================================
Files 177 177
Lines 25182 25311 +129
Branches 3546 3561 +15
==========================================
+ Hits 21699 21826 +127
Misses 3061 3061
- Partials 422 424 +2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, this should be added to some (new?) userapi notebook ?
59dd033
to
1d4d7c3
Compare
@FabioLuporini discovered some deeper issue I have to work on so lots of that may change. Maybe we want to put a small PR for Diff objects with single function in it first (one line change) |
91d93ad
to
1077067
Compare
6f47540
to
f519444
Compare
@@ -421,7 +421,7 @@ def test_fd_adjoint(self, so, ndim, derivative, adjoint_name): | |||
deriv = getattr(f, derivative) | |||
coeff = 1 if derivative == 'dx2' else -1 | |||
expected = coeff * getattr(f, derivative).evaluate.subs({x.spacing: -x.spacing}) | |||
assert deriv.T.evaluate == expected | |||
assert simplify(deriv.T.evaluate) == simplify(expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is simplify now needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because now subs is ours fully here and creates (1/_h_x) * f(x)
instead of f(x)/h_x
so doesn match without simplify (compiler refactorize so no flop increase issue)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so is it missing a SymPy evaluation somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could make it evaluate but that's be quite expensive for more complex expressions and not necessary.
@@ -59,3 +76,87 @@ def test_is_param(ndim): | |||
for dd in d: | |||
avg = .5 * (avg + avg.subs({dd: dd - dd.spacing})) | |||
assert f2._eval_at(var).evaluate == avg | |||
|
|||
|
|||
@pytest.mark.parametrize('expr, expected', [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth adding a more intricate composite expression also?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as I wrote above, yes, and perhaps x-fail it if it needs to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No
Looks good. Some nitpicking above. |
@@ -59,3 +76,87 @@ def test_is_param(ndim): | |||
for dd in d: | |||
avg = .5 * (avg + avg.subs({dd: dd - dd.spacing})) | |||
assert f2._eval_at(var).evaluate == avg | |||
|
|||
|
|||
@pytest.mark.parametrize('expr, expected', [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as I wrote above, yes, and perhaps x-fail it if it needs to
4551021
to
c6fe52d
Compare
@@ -421,7 +421,7 @@ def test_fd_adjoint(self, so, ndim, derivative, adjoint_name): | |||
deriv = getattr(f, derivative) | |||
coeff = 1 if derivative == 'dx2' else -1 | |||
expected = coeff * getattr(f, derivative).evaluate.subs({x.spacing: -x.spacing}) | |||
assert deriv.T.evaluate == expected | |||
assert simplify(deriv.T.evaluate) == simplify(expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so is it missing a SymPy evaluation somewhere?
2ec990b
to
085f232
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so I still don't understand the dichotomy Add vs Mul, and I'd like to clarify that, potentially offline if that makes it quicker.
the PR is approved though
fd: mul bug fix for Pow and derivs fd: handle pow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are stylistic things I don't like (too many new functions/methods used in only one place), but they cannot be a stopper. So for me this is GTG.
Fixes handling of expression with multiple Function and multiple staggering.
Important note. I had to make a choice on the priority levels of each staggering that is
param < not staggered, NODE < staggered
This example from slack now produce same output for bot operators
fixes #1248