Skip to content

Commit e5fb8ed

Browse files
committed
tests: Add deprecation warning for old subdomain API and update tests
1 parent 91e40da commit e5fb8ed

File tree

4 files changed

+139
-128
lines changed

4 files changed

+139
-128
lines changed

devito/deprecations.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,23 @@ class DevitoDeprecation():
77
@cached_property
88
def coeff_warn(self):
99
warn("The Coefficient API is deprecated and will be removed, coefficients should"
10-
"be passed directly to the derivative object `u.dx(weights=...)",
10+
" be passed directly to the derivative object `u.dx(weights=...)",
1111
DeprecationWarning, stacklevel=2)
1212
return
1313

1414
@cached_property
1515
def symbolic_warn(self):
1616
warn("coefficients='symbolic' is deprecated, coefficients should"
17-
"be passed directly to the derivative object `u.dx(weights=...)",
17+
" be passed directly to the derivative object `u.dx(weights=...)",
18+
DeprecationWarning, stacklevel=2)
19+
return
20+
21+
@cached_property
22+
def subdomain_warn(self):
23+
warn("Passing `SubDomain`s to `Grid` on instantiation using `mygrid ="
24+
" Grid(..., subdomains=(mydomain, ...))` is deprecated. The `Grid`"
25+
" should instead be passed as a kwarg when instantiating a subdomain"
26+
" `mydomain = MyDomain(grid=mygrid)`",
1827
DeprecationWarning, stacklevel=2)
1928
return
2029

devito/types/grid.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from devito.types.dimension import (Dimension, SpaceDimension, TimeDimension,
1818
Spacing, SteppingDimension, SubDimension,
1919
MultiSubDimension, DefaultDimension)
20+
from devito.deprecations import deprecations
2021

2122
__all__ = ['Grid', 'SubDomain', 'SubDomainSet']
2223

@@ -211,6 +212,8 @@ def __init__(self, shape, extent=None, origin=None, dimensions=None,
211212
raise ValueError("`time_dimension` must be None or of type TimeDimension")
212213

213214
# Initialize SubDomains for legacy interface
215+
if subdomains is not None:
216+
deprecations.subdomain_warn
214217
self._subdomains = tuple(i for i in (Domain(), Interior(), *as_tuple(subdomains)))
215218
for i in self._subdomains:
216219
i.__subdomain_finalize_legacy__(self)

examples/userapi/07_functions_on_subdomains.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3015,7 +3015,7 @@
30153015
"metadata": {},
30163016
"outputs": [],
30173017
"source": [
3018-
"assert np.isclose(np.linalg.norm(rec.data), 4263.564, atol=0, rtol=1e-4)"
3018+
"assert np.isclose(np.linalg.norm(rec.data), 4263.511, atol=0, rtol=1e-4)"
30193019
]
30203020
}
30213021
],

0 commit comments

Comments
 (0)