Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
Provide shape info in shape mismatch error. (pydata#3619)
Browse files Browse the repository at this point in the history
* Provide shape info in shape mismatch error.

* Reword error message.

Co-Authored-By: Deepak Cherian <[email protected]>
  • Loading branch information
danielballan and dcherian committed Dec 13, 2019
1 parent 23d76b4 commit f2b2f9f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion xarray/core/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,10 @@ def data(self):
def data(self, data):
data = as_compatible_data(data)
if data.shape != self.shape:
raise ValueError("replacement data must match the Variable's shape")
raise ValueError(
f"replacement data must match the Variable's shape. "
f"replacement data has shape {data.shape}; Variable has shape {self.shape}"
)
self._data = data

def load(self, **kwargs):
Expand Down

0 comments on commit f2b2f9f

Please sign in to comment.