From a114c1af5eb811ea4290921cb3731fddbfc424c0 Mon Sep 17 00:00:00 2001 From: Stephan Hoyer Date: Tue, 3 Oct 2017 18:17:42 -0700 Subject: [PATCH 1/2] Better error message for _FillValue vs missing_value conflicts --- xarray/conventions.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/xarray/conventions.py b/xarray/conventions.py index bbf2c02322f..f0a7263d085 100644 --- a/xarray/conventions.py +++ b/xarray/conventions.py @@ -858,12 +858,14 @@ def decode_cf_variable(var, concat_characters=True, mask_and_scale=True, if ('_FillValue' in attributes and not utils.equivalent(attributes['_FillValue'], attributes['missing_value'])): - raise ValueError("Discovered conflicting _FillValue " - "and missing_value. Considering " - "opening the offending dataset using " - "decode_cf=False, corrected the attributes", - "and decoding explicitly using " - "xarray.conventions.decode_cf(ds)") + raise ValueError("Conflicting _FillValue and missing_value " + "attributes on a variable: {} vs. {}\n\n" + "Consider opening the offending dataset " + "using decode_cf=False, corrected the " + "attributes and decoding explicitly using " + "xarray.decode_cf()." + .format(attributes['_FillValue'], + attributes['missing_value'])) attributes['_FillValue'] = attributes.pop('missing_value') fill_value = np.array(pop_to(attributes, encoding, '_FillValue')) if fill_value.size > 1: From e91de8bfa20bfc6eeb160dc587ed56e0b2d6ea1c Mon Sep 17 00:00:00 2001 From: Stephan Hoyer Date: Tue, 3 Oct 2017 19:00:21 -0700 Subject: [PATCH 2/2] Grammar --- xarray/conventions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/conventions.py b/xarray/conventions.py index f0a7263d085..d5394d5b2e1 100644 --- a/xarray/conventions.py +++ b/xarray/conventions.py @@ -861,7 +861,7 @@ def decode_cf_variable(var, concat_characters=True, mask_and_scale=True, raise ValueError("Conflicting _FillValue and missing_value " "attributes on a variable: {} vs. {}\n\n" "Consider opening the offending dataset " - "using decode_cf=False, corrected the " + "using decode_cf=False, correcting the " "attributes and decoding explicitly using " "xarray.decode_cf()." .format(attributes['_FillValue'],