@@ -27,37 +27,6 @@ def fixture_grid():
27
27
return load_static_earth_relief ()
28
28
29
29
30
- @pytest .fixture (scope = "module" , name = "expected_clipped_grid" )
31
- def fixture_expected_clipped_grid ():
32
- """
33
- The expected grdclip grid result.
34
- """
35
- return xr .DataArray (
36
- data = [
37
- [1000.0 , 570.5 , - 1000.0 , - 1000.0 ],
38
- [1000.0 , 1000.0 , 571.5 , 638.5 ],
39
- [555.5 , 556.0 , 580.0 , 1000.0 ],
40
- ],
41
- coords = {"lon" : [- 52.5 , - 51.5 , - 50.5 , - 49.5 ], "lat" : [- 18.5 , - 17.5 , - 16.5 ]},
42
- dims = ["lat" , "lon" ],
43
- )
44
-
45
-
46
- @pytest .fixture (scope = "module" , name = "expected_equalized_grid" )
47
- def fixture_expected_equalized_grid ():
48
- """
49
- The expected grdhisteq grid result.
50
- """
51
- return xr .DataArray (
52
- data = [[0 , 0 , 0 , 1 ], [0 , 0 , 0 , 1 ], [0 , 0 , 1 , 1 ], [1 , 1 , 1 , 1 ]],
53
- coords = {
54
- "lon" : [- 51.5 , - 50.5 , - 49.5 , - 48.5 ],
55
- "lat" : [- 21.5 , - 20.5 , - 19.5 , - 18.5 ],
56
- },
57
- dims = ["lat" , "lon" ],
58
- )
59
-
60
-
61
30
def test_xarray_accessor_gridline_cartesian ():
62
31
"""
63
32
Check that the accessor returns the correct registration and gtype values for a
@@ -211,7 +180,7 @@ def test_xarray_accessor_tiled_grid_slice_and_add():
211
180
assert added_grid .gmt .gtype is GridType .GEOGRAPHIC
212
181
213
182
214
- def test_xarray_accessor_clip (grid , expected_clipped_grid ):
183
+ def test_xarray_accessor_clip (grid ):
215
184
"""
216
185
Check that the accessor has the clip method and that it works correctly.
217
186
@@ -220,14 +189,33 @@ def test_xarray_accessor_clip(grid, expected_clipped_grid):
220
189
clipped_grid = grid .gmt .clip (
221
190
below = [550 , - 1000 ], above = [700 , 1000 ], region = [- 53 , - 49 , - 19 , - 16 ]
222
191
)
192
+
193
+ expected_clipped_grid = xr .DataArray (
194
+ data = [
195
+ [1000.0 , 570.5 , - 1000.0 , - 1000.0 ],
196
+ [1000.0 , 1000.0 , 571.5 , 638.5 ],
197
+ [555.5 , 556.0 , 580.0 , 1000.0 ],
198
+ ],
199
+ coords = {"lon" : [- 52.5 , - 51.5 , - 50.5 , - 49.5 ], "lat" : [- 18.5 , - 17.5 , - 16.5 ]},
200
+ dims = ["lat" , "lon" ],
201
+ )
223
202
xr .testing .assert_allclose (a = clipped_grid , b = expected_clipped_grid )
224
203
225
204
226
- def test_xarray_accessor_equalize (grid , expected_equalized_grid ):
205
+ def test_xarray_accessor_equalize (grid ):
227
206
"""
228
207
Check that the accessor has the equalize_hist method and that it works correctly.
229
208
230
209
This test is adapted from the `test_equalize_grid_no_outgrid` test.
231
210
"""
232
211
equalized_grid = grid .gmt .equalize_hist (divisions = 2 , region = [- 52 , - 48 , - 22 , - 18 ])
212
+
213
+ expected_equalized_grid = xr .DataArray (
214
+ data = [[0 , 0 , 0 , 1 ], [0 , 0 , 0 , 1 ], [0 , 0 , 1 , 1 ], [1 , 1 , 1 , 1 ]],
215
+ coords = {
216
+ "lon" : [- 51.5 , - 50.5 , - 49.5 , - 48.5 ],
217
+ "lat" : [- 21.5 , - 20.5 , - 19.5 , - 18.5 ],
218
+ },
219
+ dims = ["lat" , "lon" ],
220
+ )
233
221
xr .testing .assert_allclose (a = equalized_grid , b = expected_equalized_grid )
0 commit comments