Skip to content

Commit

Permalink
tests: Combined similar unexpansion tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EdCaunt committed Oct 27, 2023
1 parent 4f43bc9 commit a30b392
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions tests/test_unexpansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ def test_fallback_to_default(self):
op.cfunction

def test_numeric_coeffs(self):
grid = Grid(shape=(11,), extent=(10.,))
grid = Grid(shape=(11, 11), extent=(10., 10.))

u = Function(name='u', grid=grid, coefficients='symbolic', space_order=2)
v = Function(name='v', grid=grid, coefficients='symbolic', space_order=2)

coeffs = Substitutions(Coefficient(2, u, grid.dimensions[0], np.zeros(3)))
coeffs = Substitutions(Coefficient(2, u, grid.dimensions[0], np.zeros(3)),
Coefficient(2, u, grid.dimensions[1], np.zeros(3)))

opt = ('advanced', {'expand': False})

Expand All @@ -57,24 +58,8 @@ def test_numeric_coeffs(self):
# Non-perfect mixed derivative
Operator(Eq(u, (u.dx + v.dx).dx, coefficients=coeffs), opt=opt).cfunction

def test_compound_nested_subs(self):
grid = Grid(shape=(11, 11), extent=(10., 10.))
x, y = grid.dimensions
hx, hy = grid.spacing_symbols

f = Function(name='f', grid=grid, space_order=2)
p = TimeFunction(name='p', grid=grid, space_order=2,
coefficients='symbolic')

coeffs0 = np.full(3, 1)
coeffs1 = np.full(3, 2)

subs = Substitutions(Coefficient(1, p, x, coeffs0),
Coefficient(1, p, y, coeffs1))

opt = ('advanced', {'expand': False})

Operator(Eq(p.forward, (f*p.dx).dy, coefficients=subs), opt=opt).cfunction
# Compound expression
Operator(Eq(u, (v*u.dx).dy, coefficients=coeffs), opt=opt).cfunction


class Test1Pass(object):
Expand Down

0 comments on commit a30b392

Please sign in to comment.