@@ -797,13 +797,13 @@ def test_isel(self):
797797 assert_identical (self .dv [:3 , :5 ], self .dv .isel (x = slice (3 ), y = slice (5 )))
798798 with raises_regex (
799799 ValueError ,
800- r"dimensions {'not_a_dim'} do not exist. Expected "
800+ r"Dimensions {'not_a_dim'} do not exist. Expected "
801801 r"one or more of \('x', 'y'\)" ,
802802 ):
803803 self .dv .isel (not_a_dim = 0 )
804804 with pytest .warns (
805805 UserWarning ,
806- match = r"dimensions {'not_a_dim'} do not exist. "
806+ match = r"Dimensions {'not_a_dim'} do not exist. "
807807 r"Expected one or more of \('x', 'y'\)" ,
808808 ):
809809 self .dv .isel (not_a_dim = 0 , missing_dims = "warn" )
@@ -2231,9 +2231,21 @@ def test_transpose(self):
22312231 actual = da .transpose ("z" , ..., "x" , transpose_coords = True )
22322232 assert_equal (expected , actual )
22332233
2234+ # same as previous but with a missing dimension
2235+ actual = da .transpose (
2236+ "z" , "y" , "x" , "not_a_dim" , transpose_coords = True , missing_dims = "ignore"
2237+ )
2238+ assert_equal (expected , actual )
2239+
22342240 with pytest .raises (ValueError ):
22352241 da .transpose ("x" , "y" )
22362242
2243+ with pytest .raises (ValueError ):
2244+ da .transpose ("not_a_dim" , "z" , "x" , ...)
2245+
2246+ with pytest .warns (UserWarning ):
2247+ da .transpose ("not_a_dim" , "y" , "x" , ..., missing_dims = "warn" )
2248+
22372249 def test_squeeze (self ):
22382250 assert_equal (self .dv .variable .squeeze (), self .dv .squeeze ().variable )
22392251
@@ -6227,7 +6239,6 @@ def da_dask(seed=123):
62276239
62286240@pytest .mark .parametrize ("da" , ("repeating_ints" ,), indirect = True )
62296241def test_isin (da ):
6230-
62316242 expected = DataArray (
62326243 np .asarray ([[0 , 0 , 0 ], [1 , 0 , 0 ]]),
62336244 dims = list ("yx" ),
@@ -6277,7 +6288,6 @@ def test_coarsen_keep_attrs():
62776288
62786289@pytest .mark .parametrize ("da" , (1 , 2 ), indirect = True )
62796290def test_rolling_iter (da ):
6280-
62816291 rolling_obj = da .rolling (time = 7 )
62826292 rolling_obj_mean = rolling_obj .mean ()
62836293
@@ -6452,7 +6462,6 @@ def test_rolling_construct(center, window):
64526462@pytest .mark .parametrize ("window" , (1 , 2 , 3 , 4 ))
64536463@pytest .mark .parametrize ("name" , ("sum" , "mean" , "std" , "max" ))
64546464def test_rolling_reduce (da , center , min_periods , window , name ):
6455-
64566465 if min_periods is not None and window < min_periods :
64576466 min_periods = window
64586467
@@ -6491,7 +6500,6 @@ def test_rolling_reduce_nonnumeric(center, min_periods, window, name):
64916500
64926501
64936502def test_rolling_count_correct ():
6494-
64956503 da = DataArray ([0 , np .nan , 1 , 2 , np .nan , 3 , 4 , 5 , np .nan , 6 , 7 ], dims = "time" )
64966504
64976505 kwargs = [
@@ -6579,7 +6587,6 @@ def test_ndrolling_construct(center, fill_value):
65796587 ],
65806588)
65816589def test_rolling_keep_attrs (funcname , argument ):
6582-
65836590 attrs_da = {"da_attr" : "test" }
65846591
65856592 data = np .linspace (10 , 15 , 100 )
@@ -6623,7 +6630,6 @@ def test_rolling_keep_attrs(funcname, argument):
66236630
66246631
66256632def test_rolling_keep_attrs_deprecated ():
6626-
66276633 attrs_da = {"da_attr" : "test" }
66286634
66296635 data = np .linspace (10 , 15 , 100 )
@@ -6957,7 +6963,6 @@ def test_rolling_exp(da, dim, window_type, window):
69576963
69586964@requires_numbagg
69596965def test_rolling_exp_keep_attrs (da ):
6960-
69616966 attrs = {"attrs" : "da" }
69626967 da .attrs = attrs
69636968
0 commit comments