@@ -35,7 +35,7 @@ def _infer_coords_and_dims(shape, coords, dims):
35
35
"""All the logic for creating a new DataArray"""
36
36
37
37
if (coords is not None and not utils .is_dict_like (coords ) and
38
- len (coords ) != len (shape )):
38
+ len (coords ) != len (shape )):
39
39
raise ValueError ('coords is not dict-like, but it has %s items, '
40
40
'which does not match the %s dimensions of the '
41
41
'data' % (len (coords ), len (shape )))
@@ -50,8 +50,8 @@ def _infer_coords_and_dims(shape, coords, dims):
50
50
if utils .is_dict_like (coords ):
51
51
# deprecated in GH993, removed in GH1539
52
52
raise ValueError ('inferring DataArray dimensions from '
53
- 'dictionary like ``coords`` has been '
54
- 'deprecated . Use an explicit list of '
53
+ 'dictionary like ``coords`` is no longer '
54
+ 'supported . Use an explicit list of '
55
55
'``dims`` instead.' )
56
56
for n , (dim , coord ) in enumerate (zip (dims , coords )):
57
57
coord = as_variable (coord ,
@@ -87,6 +87,12 @@ def _infer_coords_and_dims(shape, coords, dims):
87
87
'length %s on the data but length %s on '
88
88
'coordinate %r' % (d , sizes [d ], s , k ))
89
89
90
+ if k in sizes and v .shape != (sizes [k ],):
91
+ raise ValueError ('coordinate %r is a DataArray dimension, but '
92
+ 'it has shape %r rather than expected shape %r '
93
+ 'matching the dimension size'
94
+ % (k , v .shape , (sizes [k ],)))
95
+
90
96
assert_unique_multiindex_level_names (new_coords )
91
97
92
98
return new_coords , dims
0 commit comments