18
18
),
19
19
],
20
20
)
21
- @pytest .mark .parametrize ("idxnames" , ["landpoint" , ("landpoint" ,), None ])
21
+ @pytest .mark .parametrize ("idxnames" , ["foo" , " landpoint" , ("landpoint" ,), None ])
22
22
def test_compression_by_gathering_multi_index_roundtrip (mindex , idxnames ):
23
+ dim = "foo" if idxnames == "foo" else "landpoint"
23
24
dataset = xr .Dataset (
24
- data_vars = {"landsoilt" : ("landpoint" , np .random .randn (4 ), {"foo" : "bar" })},
25
+ data_vars = {"landsoilt" : (dim , np .random .randn (4 ), {"foo" : "bar" })},
25
26
coords = {
26
- "landpoint" : ("landpoint" , mindex , {"long_name" : "land point number" }),
27
- "coord1" : ("landpoint" , [1 , 2 , 3 , 4 ], {"foo" : "baz" }),
27
+ dim : (dim , mindex , {"long_name" : "land point number" }),
28
+ "coord1" : (dim , [1 , 2 , 3 , 4 ], {"foo" : "baz" }),
28
29
},
29
30
attrs = {"dataset" : "test dataset" },
30
31
)
@@ -33,9 +34,9 @@ def test_compression_by_gathering_multi_index_roundtrip(mindex, idxnames):
33
34
34
35
encoded = cfxr .encode_multi_index_as_compress (dataset , idxnames )
35
36
roundtrip = cfxr .decode_compress_to_multi_index (encoded , idxnames )
36
- assert "compress" not in roundtrip ["landpoint" ].encoding
37
+ assert "compress" not in roundtrip [dim ].encoding
37
38
xr .testing .assert_identical (roundtrip , dataset )
38
39
39
- dataset ["landpoint" ].attrs ["compress" ] = "lat lon"
40
+ dataset [dim ].attrs ["compress" ] = "lat lon"
40
41
with pytest .raises (ValueError ):
41
42
cfxr .encode_multi_index_as_compress (dataset , idxnames )
0 commit comments