@@ -2367,6 +2367,29 @@ def test_open_single_dataset(self):
2367
2367
with open_mfdataset ([tmp ], concat_dim = dim ) as actual :
2368
2368
assert_identical (expected , actual )
2369
2369
2370
+ def test_open_multi_dataset (self ):
2371
+ # Test for issue GH #1988 and #2647. This makes sure that the
2372
+ # concat_dim is utilized when specified in open_mfdataset().
2373
+ # The additional wrinkle is to ensure that a length greater
2374
+ # than one is tested as well due to numpy's implicit casting
2375
+ # of 1-length arrays to booleans in tests, which allowed
2376
+ # #2647 to still pass the test_open_single_dataset(),
2377
+ # which is itself still needed as-is because the original
2378
+ # bug caused one-length arrays to not be used correctly
2379
+ # in concatenation.
2380
+ rnddata = np .random .randn (10 )
2381
+ original = Dataset ({'foo' : ('x' , rnddata )})
2382
+ dim = DataArray ([100 , 150 ], name = 'baz' , dims = 'baz' )
2383
+ expected = Dataset ({'foo' : (('baz' , 'x' ),
2384
+ np .tile (rnddata [np .newaxis , :], (2 , 1 )))},
2385
+ {'baz' : [100 , 150 ]})
2386
+ with create_tmp_file () as tmp1 , \
2387
+ create_tmp_file () as tmp2 :
2388
+ original .to_netcdf (tmp1 )
2389
+ original .to_netcdf (tmp2 )
2390
+ with open_mfdataset ([tmp1 , tmp2 ], concat_dim = dim ) as actual :
2391
+ assert_identical (expected , actual )
2392
+
2370
2393
def test_dask_roundtrip (self ):
2371
2394
with create_tmp_file () as tmp :
2372
2395
data = create_test_data ()
0 commit comments