-
Notifications
You must be signed in to change notification settings - Fork 166
Move __future__
interpolation into interpolation.py
#4346
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
Open
leo-collins
wants to merge
26
commits into
master
Choose a base branch
from
new-interpolate
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
5f34b01
replace `Interpolator.__new__`
leo-collins 629259d
change `Interpolator._interpolate_future` to `Interpolator.interpolate`
leo-collins c52b530
replace `interpolate` function
leo-collins 3399e32
update `interpolate` docstring
leo-collins 782f737
remove `firedrake.__future__` imports
leo-collins 52a9399
delete contents of `__future__`
leo-collins 47cea69
remove instruction to import `__future__.interpolate` from interpolat…
leo-collins cfffebb
update `Interpolator.interpolate` docstring
leo-collins 9ee45b2
update benny_luke demo
leo-collins 3d189a0
update full_waveform_inversion demo
leo-collins f440237
fixed typo
leo-collins bb32905
fix
leo-collins 0278146
wrap `interpolate` inside `__future__`
leo-collins 182010c
fix `__new__` method of `Interpolator`
leo-collins ac81b56
add warning to `__future__.interpolate`
leo-collins 42202d5
add deprecation warning to `__future__.interpolate`
leo-collins 5372efa
wrap `Interpolate` class in `__future__` with deprecation warning
leo-collins 32aa021
update warning message
leo-collins 87b0174
change warning text
leo-collins 70169a4
fix notebooks
leo-collins 89565e7
lint
leo-collins 74686c8
use `warnings.warn` instead of `warnings.deprecated`
leo-collins a48fd7c
lint
leo-collins f4b5280
fix import in `hypre_ams.py`
leo-collins 4ab4347
more import fixes
leo-collins d7b8b2f
add clarification on adjoint interpolation
leo-collins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,16 @@ | ||
from ufl.domain import as_domain, extract_unique_domain | ||
from ufl.algorithms import extract_arguments | ||
from firedrake.mesh import MeshTopology, VertexOnlyMeshTopology | ||
from firedrake.interpolation import (interpolate as interpolate_old, | ||
Interpolator as InterpolatorOld, | ||
SameMeshInterpolator as SameMeshInterpolatorOld, | ||
CrossMeshInterpolator as CrossMeshInterpolatorOld) | ||
from firedrake.cofunction import Cofunction | ||
from functools import wraps | ||
from firedrake.interpolation import interpolate as interpolate_default, Interpolator as Interpolator_default | ||
import warnings | ||
|
||
|
||
__all__ = ("interpolate", "Interpolator") | ||
|
||
|
||
class Interpolator(InterpolatorOld): | ||
def __new__(cls, expr, V, **kwargs): | ||
target_mesh = as_domain(V) | ||
source_mesh = extract_unique_domain(expr) or target_mesh | ||
if target_mesh is source_mesh or all(isinstance(m.topology, MeshTopology) for m in [target_mesh, source_mesh]) and target_mesh.submesh_ancesters[-1] is source_mesh.submesh_ancesters[-1]: | ||
return object.__new__(SameMeshInterpolator) | ||
else: | ||
if isinstance(target_mesh.topology, VertexOnlyMeshTopology): | ||
return object.__new__(SameMeshInterpolator) | ||
else: | ||
return object.__new__(CrossMeshInterpolator) | ||
|
||
interpolate = InterpolatorOld._interpolate_future | ||
|
||
|
||
class SameMeshInterpolator(Interpolator, SameMeshInterpolatorOld): | ||
pass | ||
|
||
|
||
class CrossMeshInterpolator(Interpolator, CrossMeshInterpolatorOld): | ||
pass | ||
def interpolate(expr, V, *args, **kwargs): | ||
warnings.warn("""The symbolic `interpolate` has been moved into `firedrake` | ||
and is now the default method for interpolating in Firedrake. The need to | ||
`from firedrake.__future__ import interpolate` is now deprecated.""", FutureWarning) | ||
return interpolate_default(expr, V, *args, **kwargs) | ||
|
||
|
||
@wraps(interpolate_old) | ||
def interpolate(expr, V, *args, **kwargs): | ||
default_missing_val = kwargs.pop("default_missing_val", None) | ||
if isinstance(V, Cofunction): | ||
adjoint = bool(extract_arguments(expr)) | ||
return Interpolator( | ||
expr, V.function_space().dual(), *args, **kwargs | ||
).interpolate(V, adjoint=adjoint, default_missing_val=default_missing_val) | ||
return Interpolator(expr, V, *args, **kwargs).interpolate(default_missing_val=default_missing_val) | ||
class Interpolator(Interpolator_default): | ||
def __new__(cls, *args, **kwargs): | ||
warnings.warn("""The symbolic `Interpolator` has been moved into `firedrake`. | ||
The need to `from firedrake.__future__ import Interpolator` is now deprecated.""", FutureWarning) | ||
return Interpolator_default(*args, **kwargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.