@@ -280,8 +280,10 @@ def test_get_new_tile_ids(self, create_combined_ids):
280
280
281
281
282
282
class TestCombineND :
283
- @pytest .mark .parametrize ("concat_dim" , ["dim1" , "new_dim" ])
284
- def test_concat_once (self , create_combined_ids , concat_dim ):
283
+ @pytest .mark .parametrize (
284
+ "concat_dim, kwargs" , [("dim1" , {}), ("new_dim" , {"data_vars" : "all" })]
285
+ )
286
+ def test_concat_once (self , create_combined_ids , concat_dim , kwargs ):
285
287
shape = (2 ,)
286
288
combined_ids = create_combined_ids (shape )
287
289
ds = create_test_data
@@ -296,7 +298,7 @@ def test_concat_once(self, create_combined_ids, concat_dim):
296
298
combine_attrs = "drop" ,
297
299
)
298
300
299
- expected_ds = concat ([ds (0 ), ds (1 )], data_vars = "all" , dim = concat_dim )
301
+ expected_ds = concat ([ds (0 ), ds (1 )], dim = concat_dim , ** kwargs )
300
302
assert_combined_tile_ids_equal (result , {(): expected_ds })
301
303
302
304
def test_concat_only_first_dim (self , create_combined_ids ):
@@ -322,8 +324,10 @@ def test_concat_only_first_dim(self, create_combined_ids):
322
324
323
325
assert_combined_tile_ids_equal (result , expected )
324
326
325
- @pytest .mark .parametrize ("concat_dim" , ["dim1" , "new_dim" ])
326
- def test_concat_twice (self , create_combined_ids , concat_dim ):
327
+ @pytest .mark .parametrize (
328
+ "concat_dim, kwargs" , [("dim1" , {}), ("new_dim" , {"data_vars" : "all" })]
329
+ )
330
+ def test_concat_twice (self , create_combined_ids , concat_dim , kwargs ):
327
331
shape = (2 , 3 )
328
332
combined_ids = create_combined_ids (shape )
329
333
result = _combine_nd (
@@ -341,9 +345,7 @@ def test_concat_twice(self, create_combined_ids, concat_dim):
341
345
partway1 = concat ([ds (0 ), ds (3 )], dim = "dim1" )
342
346
partway2 = concat ([ds (1 ), ds (4 )], dim = "dim1" )
343
347
partway3 = concat ([ds (2 ), ds (5 )], dim = "dim1" )
344
- expected = concat (
345
- [partway1 , partway2 , partway3 ], data_vars = "all" , dim = concat_dim
346
- )
348
+ expected = concat ([partway1 , partway2 , partway3 ], ** kwargs , dim = concat_dim )
347
349
348
350
assert_equal (result , expected )
349
351
@@ -448,15 +450,19 @@ def test_nested_concat_along_new_dim(self):
448
450
449
451
def test_nested_merge_with_self (self ):
450
452
data = Dataset ({"x" : 0 })
451
- actual = combine_nested (
452
- [data , data , data ], compat = "no_conflicts" , concat_dim = None
453
- )
453
+ actual = combine_nested ([data , data , data ], concat_dim = None )
454
454
assert_identical (data , actual )
455
455
456
456
def test_nested_merge_with_overlapping_values (self ):
457
457
ds1 = Dataset ({"a" : ("x" , [1 , 2 ]), "x" : [0 , 1 ]})
458
458
ds2 = Dataset ({"a" : ("x" , [2 , 3 ]), "x" : [1 , 2 ]})
459
459
expected = Dataset ({"a" : ("x" , [1 , 2 , 3 ]), "x" : [0 , 1 , 2 ]})
460
+ with pytest .warns (
461
+ FutureWarning ,
462
+ match = "will change from compat='no_conflicts' to compat='override'" ,
463
+ ):
464
+ actual = combine_nested ([ds1 , ds2 ], join = "outer" , concat_dim = None )
465
+ assert_identical (expected , actual )
460
466
actual = combine_nested (
461
467
[ds1 , ds2 ], join = "outer" , compat = "no_conflicts" , concat_dim = None
462
468
)
@@ -466,11 +472,16 @@ def test_nested_merge_with_overlapping_values(self):
466
472
)
467
473
assert_identical (expected , actual )
468
474
469
- def test_nested_merge_with_nan (self ):
475
+ def test_nested_merge_with_nan_no_conflicts (self ):
470
476
tmp1 = Dataset ({"x" : 0 })
471
477
tmp2 = Dataset ({"x" : np .nan })
472
478
actual = combine_nested ([tmp1 , tmp2 ], compat = "no_conflicts" , concat_dim = None )
473
479
assert_identical (tmp1 , actual )
480
+ with pytest .warns (
481
+ FutureWarning ,
482
+ match = "will change from compat='no_conflicts' to compat='override'" ,
483
+ ):
484
+ combine_nested ([tmp1 , tmp2 ], concat_dim = None )
474
485
actual = combine_nested ([tmp1 , tmp2 ], compat = "no_conflicts" , concat_dim = [None ])
475
486
assert_identical (tmp1 , actual )
476
487
@@ -543,7 +554,6 @@ def test_auto_combine_2d(self):
543
554
result = combine_nested (
544
555
datasets ,
545
556
data_vars = "all" ,
546
- compat = "no_conflicts" ,
547
557
concat_dim = ["dim1" , "dim2" ],
548
558
)
549
559
assert_equal (result , expected )
@@ -588,7 +598,6 @@ def test_auto_combine_2d_combine_attrs_kwarg(self):
588
598
datasets ,
589
599
concat_dim = ["dim1" , "dim2" ],
590
600
data_vars = "all" ,
591
- compat = "no_conflicts" ,
592
601
combine_attrs = "identical" ,
593
602
)
594
603
@@ -597,7 +606,6 @@ def test_auto_combine_2d_combine_attrs_kwarg(self):
597
606
datasets ,
598
607
concat_dim = ["dim1" , "dim2" ],
599
608
data_vars = "all" ,
600
- compat = "no_conflicts" ,
601
609
combine_attrs = combine_attrs ,
602
610
)
603
611
assert_identical (result , expected )
@@ -995,9 +1003,7 @@ def test_combine_by_coords_combine_attrs_variables(
995
1003
with pytest .raises (MergeError , match = "combine_attrs" ):
996
1004
combine_by_coords ([data1 , data2 ], combine_attrs = combine_attrs )
997
1005
else :
998
- actual = combine_by_coords (
999
- [data1 , data2 ], data_vars = "all" , combine_attrs = combine_attrs
1000
- )
1006
+ actual = combine_by_coords ([data1 , data2 ], combine_attrs = combine_attrs )
1001
1007
expected = Dataset (
1002
1008
{
1003
1009
"x" : ("a" , [0 , 1 ], expected_attrs ),
@@ -1011,7 +1017,7 @@ def test_combine_by_coords_combine_attrs_variables(
1011
1017
def test_infer_order_from_coords (self ):
1012
1018
data = create_test_data ()
1013
1019
objs = [data .isel (dim2 = slice (4 , 9 )), data .isel (dim2 = slice (4 ))]
1014
- actual = combine_by_coords (objs , data_vars = "all" , compat = "no_conflicts" )
1020
+ actual = combine_by_coords (objs , data_vars = "all" )
1015
1021
expected = data
1016
1022
assert expected .broadcast_equals (actual )
1017
1023
@@ -1178,9 +1184,7 @@ def test_combine_by_coords_all_dataarrays_with_the_same_name(self):
1178
1184
named_da1 = DataArray (name = "a" , data = [1.0 , 2.0 ], coords = {"x" : [0 , 1 ]}, dims = "x" )
1179
1185
named_da2 = DataArray (name = "a" , data = [3.0 , 4.0 ], coords = {"x" : [2 , 3 ]}, dims = "x" )
1180
1186
1181
- actual = combine_by_coords (
1182
- [named_da1 , named_da2 ], compat = "no_conflicts" , join = "outer"
1183
- )
1187
+ actual = combine_by_coords ([named_da1 , named_da2 ], join = "outer" )
1184
1188
expected = merge ([named_da1 , named_da2 ], compat = "no_conflicts" , join = "outer" )
1185
1189
assert_identical (expected , actual )
1186
1190
0 commit comments