From f2b2f9f62ea0f1020262a7ff563bfe74258ffaa1 Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Fri, 13 Dec 2019 11:05:23 -0500 Subject: [PATCH] Provide shape info in shape mismatch error. (#3619) * Provide shape info in shape mismatch error. * Reword error message. Co-Authored-By: Deepak Cherian --- xarray/core/variable.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xarray/core/variable.py b/xarray/core/variable.py index ac4b367f66d..17ecdf62730 100644 --- a/xarray/core/variable.py +++ b/xarray/core/variable.py @@ -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):