Skip to content

Commit f2b2f9f

Browse files
Provide shape info in shape mismatch error. (#3619)
* Provide shape info in shape mismatch error. * Reword error message. Co-Authored-By: Deepak Cherian <[email protected]>
1 parent 23d76b4 commit f2b2f9f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

xarray/core/variable.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,10 @@ def data(self):
346346
def data(self, data):
347347
data = as_compatible_data(data)
348348
if data.shape != self.shape:
349-
raise ValueError("replacement data must match the Variable's shape")
349+
raise ValueError(
350+
f"replacement data must match the Variable's shape. "
351+
f"replacement data has shape {data.shape}; Variable has shape {self.shape}"
352+
)
350353
self._data = data
351354

352355
def load(self, **kwargs):

0 commit comments

Comments
 (0)