Skip to content

Commit 6e73884

Browse files
committed
tests: Add test for python-level printing to improve coverage
1 parent bda80fe commit 6e73884

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

devito/ir/equations/equation.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@ def directions(self):
4949
@property
5050
def dtype(self):
5151
try:
52-
rhs_dtype = self.rhs.dtype
52+
return infer_dtype({self.lhs.dtype, self.rhs.dtype} - {None})
5353
except AttributeError:
54-
rhs_dtype = None
55-
56-
return infer_dtype({self.lhs.dtype, rhs_dtype} - {None})
54+
return self.lhs.dtype
5755

5856
@property
5957
def state(self):

devito/passes/iet/languages/C.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,9 @@ def _print_ImaginaryUnit(self, expr):
5757
return '_Complex_I'
5858

5959
def _print_Re(self, expr):
60-
"""Print an Re as an access into the second entry of a float array."""
6160
return (f'{self.func_prefix(expr)}real{self.func_literal(expr).lower()}'
6261
f'({self._print(expr.args[0])})')
6362

6463
def _print_Im(self, expr):
65-
"""Print an Im as an access into the second entry of a float array."""
6664
return (f'{self.func_prefix(expr)}imag{self.func_literal(expr).lower()}'
6765
f'({self._print(expr.args[0])})')

tests/test_symbolics.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,12 @@ def run_operator(self, eqs, language):
890890
with switchconfig(language=language):
891891
Operator(eqs)()
892892

893+
def test_devito_print(self):
894+
f, _, _ = self.setup_basic(np.complex64)
895+
896+
assert str(Re(f)) == 'Re(f(x))'
897+
assert str(Im(f)) == 'Im(f(x))'
898+
893899
@pytest.mark.parametrize('language', ['C', 'CXX', 'CXXopenmp'])
894900
def test_printing(self, language):
895901
f, f_real, f_imag = self.setup_basic(np.complex64)

0 commit comments

Comments
 (0)