@@ -51,7 +51,7 @@ def test_numeric_coeffs(self):
5151 Operator (Eq (u , (v * u .dx ).dy (weights = w )), opt = opt ).cfunction
5252
5353 @pytest .mark .parametrize ('coeffs,expected' , [
54- ((7 , 7 , 7 ), 1 ), # We've had a bug triggered by identical coeffs
54+ ((7 , 7 , 7 ), 3 ), # We've had a bug triggered by identical coeffs
5555 ((5 , 7 , 9 ), 3 ),
5656 ])
5757 def test_multiple_cross_derivs (self , coeffs , expected ):
@@ -89,7 +89,8 @@ def test_legacy_api(self, order, nweight):
8989 coefficients = 'symbolic' )
9090
9191 w0 = np .arange (so + 1 + nweight ) + 1
92- wstr = '{' + ', ' .join ([f"{ w :1.1f} F" for w in w0 ]) + '}'
92+ s = f'({ x .spacing } *{ x .spacing } )' if order == 2 else f'{ x .spacing } '
93+ wstr = f'{{{ w0 [0 ]:1.1f} F/{ s } ,'
9394 wdef = f'[{ so + 1 + nweight } ] __attribute__ ((aligned (64)))'
9495
9596 coeffs_x_p1 = Coefficient (order , u , x , w0 )
@@ -105,6 +106,29 @@ def test_legacy_api(self, order, nweight):
105106 op = Operator (eqn , opt = ('advanced' , {'expand' : False }))
106107 assert f'{ wdef } = { wstr } ' in str (op )
107108
109+ def test_legacy_api_v2 (self ):
110+ grid = Grid (shape = (10 , 10 , 10 ))
111+ x , y , z = grid .dimensions
112+
113+ u = TimeFunction (name = 'u' , grid = grid , space_order = 4 )
114+
115+ cc = np .array ([2 , 2 , 2 , 2 , 2 ])
116+ coeffs = [Coefficient (1 , u , d , cc ) for d in grid .dimensions ]
117+ coeffs = Substitutions (* coeffs )
118+
119+ eq0 = Eq (u .forward , u .dx .dz + 1.0 )
120+ eq1 = Eq (u .forward , u .dx .dz + 1.0 , coefficients = coeffs )
121+
122+ op0 = Operator (eq0 , opt = ('advanced' , {'expand' : False }))
123+ op1 = Operator (eq1 , opt = ('advanced' , {'expand' : False }))
124+
125+ assert (op0 ._profiler ._sections ['section0' ].sops ==
126+ op1 ._profiler ._sections ['section0' ].sops )
127+ weights = [i for i in FindSymbols ().visit (op1 ) if isinstance (i , Weights )]
128+ w0 , w1 = sorted (weights , key = lambda i : i .name )
129+ assert all (i .args [1 ] == 1 / x .spacing for i in w0 .weights )
130+ assert all (i .args [1 ] == 1 / z .spacing for i in w1 .weights )
131+
108132
109133class Test1Pass :
110134
0 commit comments