@@ -1332,11 +1332,11 @@ def test_expand_dims_error(self):
13321332 coords = {'x' : np .linspace (0.0 , 1.0 , 3 )},
13331333 attrs = {'key' : 'entry' })
13341334 with pytest .raises (TypeError ):
1335- array .expand_dims ({ "new_dim" : 3.2 } )
1335+ array .expand_dims (OrderedDict ((( "new_dim" , 3.2 ),)) )
13361336
13371337 # Attempt to use both dim and kwargs
13381338 with pytest .raises (ValueError ):
1339- array .expand_dims ({ "d" : 4 } , e = 4 )
1339+ array .expand_dims (OrderedDict ((( "d" , 4 ),)) , e = 4 )
13401340
13411341 def test_expand_dims (self ):
13421342 array = DataArray (np .random .randn (3 , 4 ), dims = ['x' , 'dim_0' ],
@@ -1403,10 +1403,6 @@ def test_expand_dims_with_scalar_coordinate(self):
14031403 assert_identical (array , roundtripped )
14041404
14051405 def test_expand_dims_with_greater_dim_size (self ):
1406- """Python 3.6+ dicts keep insertion order, unlike Python 3.5 and
1407- earlier. Therefore the following tests have to use ordered dicts to
1408- pass for python 3.5 and earlier.
1409- """
14101406 array = DataArray (np .random .randn (3 , 4 ), dims = ['x' , 'dim_0' ],
14111407 coords = {'x' : np .linspace (0.0 , 1.0 , 3 ), 'z' : 1.0 },
14121408 attrs = {'key' : 'entry' })
@@ -1426,19 +1422,15 @@ def test_expand_dims_with_greater_dim_size(self):
14261422 assert_identical (expected , actual )
14271423
14281424 # Test with kwargs instead of passing dict to dim arg.
1429- other_way = array .expand_dims (y = 2 , z = 1 , dim_1 = ['a' , 'b' , 'c' ])
1430- # Unfortunately, there is no way to maintain insertion order with
1431- # kwargs in python 3.5 and earlier, so for now we have to ensure the
1432- # dimensions of the expected result are in the same order as the actual
1433- # result to allow the test to pass.
1434- other_way_expected_coords = OrderedDict ()
1435- for dim in other_way .dims :
1436- other_way_expected_coords [dim ] = expected_coords [dim ]
1425+ other_way = array .expand_dims (dim_1 = ['a' , 'b' , 'c' ])
1426+
14371427 other_way_expected = DataArray (
1438- array .values * np .ones (list (other_way .shape )),
1439- coords = other_way_expected_coords ,
1440- dims = list (other_way_expected_coords .keys ()),
1441- attrs = {'key' : 'entry' }).drop (['y' , 'dim_0' ])
1428+ array .values * np .ones ([3 , 3 , 4 ]),
1429+ coords = {'dim_1' : ['a' , 'b' , 'c' ],
1430+ 'x' : np .linspace (0 , 1 , 3 ),
1431+ 'dim_0' : range (4 ), 'z' : 1.0 },
1432+ dims = ['dim_1' , 'x' , 'dim_0' ],
1433+ attrs = {'key' : 'entry' }).drop ('dim_0' )
14421434 assert_identical (other_way_expected , other_way )
14431435
14441436 def test_set_index (self ):
0 commit comments