@@ -248,7 +248,8 @@ def test_concat(self):
248
248
249
249
# from dataset array:
250
250
expected = DataArray (np .array ([foo .values , bar .values ]),
251
- dims = ['w' , 'x' , 'y' ], coords = {'x' : [0 , 1 ]})
251
+ dims = ['w' , 'x' , 'y' ],
252
+ coords = {'x' : [0 , 1 ], 'w' : ['foo' , 'bar' ]})
252
253
actual = concat ([foo , bar ], 'w' )
253
254
assert_equal (expected , actual )
254
255
# from iteration:
@@ -297,15 +298,19 @@ def test_concat_lazy(self):
297
298
assert combined .shape == (2 , 3 , 3 )
298
299
assert combined .dims == ('z' , 'x' , 'y' )
299
300
300
- def test_concat_names (self ):
301
+ def test_concat_names_and_coords (self ):
301
302
ds = Dataset ({'foo' : (['x' , 'y' ], np .random .random ((2 , 2 ))),
302
303
'bar' : (['x' , 'y' ], np .random .random ((2 , 2 )))})
303
304
# Concat arrays with different names, new name is None
305
+ # and unique array names are used as coordinates
304
306
new = concat ([ds .foo , ds .bar ], dim = 'new' )
305
307
assert new .name is None
308
+ assert (new .coords ['new' ] == ['foo' , 'bar' ]).values .all ()
306
309
# Concat arrays with same name, name is preserved
310
+ # and non-unique names are not used as coords
307
311
foobar = ds .foo .rename ('bar' )
308
312
assert concat ([foobar , ds .bar ], dim = 'new' ).name == 'bar'
313
+ assert 'new' not in concat ([foobar , ds .bar ], dim = 'new' ).coords
309
314
310
315
311
316
class TestAutoCombine (object ):
0 commit comments