@@ -132,6 +132,24 @@ def test_real():
132132 assert s .is_imaginary is np .iscomplexobj (dtype (0 ))
133133
134134
135+ @pytest .mark .parametrize ('spacing, extent, shape, expected, broken' , [
136+ ((0.5 , 0.5 ), None , (11 , 11 ), ((0.5 , 0.5 ), (5.0 , 5.0 )), False ),
137+ (None , (5.0 , 5.0 ), (11 , 11 ), ((0.5 , 0.5 ), (5.0 , 5.0 )), False ),
138+ ((0.5 , 0.5 ), (5.0 , 5.0 ), (11 , 11 ), ((0.5 , 0.5 ), (5.0 , 5.0 )), False ),
139+ (None , (.3 , .3 ), (151 , 146 ), ((0.002 , 0.002 ), (.3 , .3 )), 'spacing' ),
140+ ((.002 , .002 ), (.3 , .3 ), (151 , 146 ), ((0.002 , 0.002 ), (.3 , .3 )), False ),
141+ ((.002 , .002 ), None , (151 , 146 ), ((0.002 , 0.002 ), (.3 , .3 )), 'extent' ),
142+ (None , None , (11 , 11 ), ((.1 , .1 ), (1.0 , 1.0 )), False ),
143+ ])
144+ def test_grid_inputs (spacing , extent , shape , expected , broken ):
145+ grid = Grid (shape = shape , spacing = spacing , extent = extent )
146+ sp , ex = expected
147+ sp = np .array (sp ).astype (grid .dtype )
148+ ex = np .array (ex ).astype (grid .dtype )
149+ assert np .allclose (grid .spacing , sp , atol = 0 , rtol = 0 ) is (broken != 'spacing' )
150+ assert np .allclose (grid .extent , ex , atol = 0 , rtol = 0 ) is (broken != 'extent' )
151+
152+
135153def test_constant ():
136154 c = Constant (name = 'c' )
137155
0 commit comments