Skip to content

Commit 41f4828

Browse files
authored
Better error message for _FillValue vs missing_value conflicts (#1602)
* Better error message for _FillValue vs missing_value conflicts * Grammar
1 parent 24643ec commit 41f4828

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

xarray/conventions.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -858,12 +858,14 @@ def decode_cf_variable(var, concat_characters=True, mask_and_scale=True,
858858
if ('_FillValue' in attributes and
859859
not utils.equivalent(attributes['_FillValue'],
860860
attributes['missing_value'])):
861-
raise ValueError("Discovered conflicting _FillValue "
862-
"and missing_value. Considering "
863-
"opening the offending dataset using "
864-
"decode_cf=False, corrected the attributes",
865-
"and decoding explicitly using "
866-
"xarray.conventions.decode_cf(ds)")
861+
raise ValueError("Conflicting _FillValue and missing_value "
862+
"attributes on a variable: {} vs. {}\n\n"
863+
"Consider opening the offending dataset "
864+
"using decode_cf=False, correcting the "
865+
"attributes and decoding explicitly using "
866+
"xarray.decode_cf()."
867+
.format(attributes['_FillValue'],
868+
attributes['missing_value']))
867869
attributes['_FillValue'] = attributes.pop('missing_value')
868870
fill_value = np.array(pop_to(attributes, encoding, '_FillValue'))
869871
if fill_value.size > 1:

0 commit comments

Comments
 (0)