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

api: cleanup FD tools and support zeroth order derivative #2368

Merged
merged 7 commits into from
May 6, 2024
Merged

Conversation

mloubout
Copy link
Contributor

@mloubout mloubout commented May 3, 2024

No description provided.

@mloubout mloubout added the API api (symbolics, types, ...) label May 3, 2024
Copy link

codecov bot commented May 3, 2024

Codecov Report

Attention: Patch coverage is 96.52174% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 86.75%. Comparing base (a400992) to head (b10ef96).

Files Patch % Lines
devito/types/basic.py 75.00% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2368   +/-   ##
=======================================
  Coverage   86.75%   86.75%           
=======================================
  Files         233      233           
  Lines       43720    43727    +7     
  Branches     8078     8072    -6     
=======================================
+ Hits        37929    37937    +8     
  Misses       5080     5080           
+ Partials      711      710    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

fmean = .5 * (f + f._subs(y, y + y.spacing))
drv1x0 = drv1(x0={y: y+y.spacing/2}).evaluate

assert simplify(fmean.dx2.evaluate - drv1x0) == 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would also be a good idea to check equivalence between the Derivative(f, y, deriv_order=0, x0=y+y.spacing/2) and Derivative(f, (y, 0), x0={y: y+y.spacing/2}) specifications.

There should also be tests for Derivative(f, (x, 0), (y, 0), x0={x: x+x.spacing/2, y: y+y.spacing/2}) and Derivative(f, x, y,, deriv_order=(0, 0), x0={x: x+x.spacing/2, y: y+y.spacing/2})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@jkwashbourne-oss
Copy link

Great work! What about a unit test interpolating an analytic function like a sin or cos?

@mloubout
Copy link
Contributor Author

mloubout commented May 3, 2024

What about a unit test interpolating an analytic function like a sin or cos?

There is a unit test checking coefficient correctness.

@mloubout mloubout force-pushed the zero-fd branch 4 times, most recently from e83e6e3 to 2fa1537 Compare May 3, 2024 17:31
@@ -831,7 +831,7 @@ def test_solve(self, operate_on_empty_cache):
# created by the finite difference (u.dt, u.dx2). We would have had
# three extra references to u(t + dt), u(x - h_x) and u(x + h_x).
# But this is not the case anymore!
assert len(_SymbolCache) == 11
assert len(_SymbolCache) == 12
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This is because now every order uses a StencilDImension even for space_order=1 while we were only giving the list of indices for that case before.

@mloubout mloubout force-pushed the zero-fd branch 3 times, most recently from 7da8195 to 7703a65 Compare May 3, 2024 19:01
@mloubout mloubout force-pushed the zero-fd branch 2 times, most recently from 358b228 to 18d1a94 Compare May 6, 2024 14:33
Copy link
Contributor

@FabioLuporini FabioLuporini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two minor comments, addressable in a separate PR, because this is good to go in my opinion

devito/types/basic.py Outdated Show resolved Hide resolved
devito/finite_differences/differentiable.py Show resolved Hide resolved
@mloubout mloubout merged commit 0e0e0ac into master May 6, 2024
31 checks passed
@mloubout mloubout deleted the zero-fd branch May 6, 2024 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API api (symbolics, types, ...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants