Skip to content

Commit a1334cb

Browse files
committed
api: silence non-Expr warning for tensor (e.g staggering/name/..)
1 parent ecc53dd commit a1334cb

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

devito/types/basic.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import abc
22
import inspect
3+
import warnings
34
from contextlib import suppress
45
from ctypes import POINTER, Structure, _Pointer, c_char, c_char_p
56
from functools import cached_property, reduce
@@ -9,6 +10,7 @@
910
import sympy
1011
from sympy.core.assumptions import _assume_rules
1112
from sympy.core.decorators import call_highest_priority
13+
from sympy.utilities.exceptions import SymPyDeprecationWarning
1214

1315
from devito.data import default_allocator
1416
from devito.parameters import configuration
@@ -1533,10 +1535,20 @@ def _sympify(self, arg):
15331535
# This is used internally by sympy to process arguments at rebuilt. And since
15341536
# some of our properties are non-sympyfiable we need to have a fallback
15351537
try:
1536-
return super()._sympify(arg)
1537-
except sympy.SympifyError:
1538+
# Pure sympy object
1539+
return arg._sympy_()
1540+
except AttributeError:
15381541
return arg
15391542

1543+
@classmethod
1544+
def _eval_from_dok(cls, rows, cols, dok):
1545+
with warnings.catch_warnings():
1546+
warnings.filterwarnings(
1547+
"ignore",
1548+
category=SymPyDeprecationWarning
1549+
)
1550+
return super()._eval_from_dok(rows, cols, dok)
1551+
15401552
@property
15411553
def grid(self):
15421554
"""

devito/types/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ def on_node(self):
5959

6060
@property
6161
def _ref(self):
62-
if self.on_node:
62+
if not self:
63+
return None
64+
elif self.on_node:
6365
return NODE
6466
else:
6567
return tuple(d for d, s in zip(self.getters, self, strict=True) if s == 1)

0 commit comments

Comments
 (0)