|
7 | 7 | import numpy as np
|
8 | 8 | import pandas as pd
|
9 | 9 |
|
10 |
| -from ..core import dtypes, duck_array_ops, indexing, utils |
| 10 | +from ..core import dtypes, duck_array_ops, indexing |
11 | 11 | from ..core.pycompat import dask_array_type
|
12 | 12 | from ..core.variable import Variable
|
13 | 13 |
|
@@ -152,26 +152,12 @@ def encode(self, variable, name=None):
|
152 | 152 | def decode(self, variable, name=None):
|
153 | 153 | dims, data, attrs, encoding = unpack_for_decoding(variable)
|
154 | 154 |
|
155 |
| - if 'missing_value' in attrs: |
156 |
| - # missing_value is deprecated, but we still want to support it as |
157 |
| - # an alias for _FillValue. |
158 |
| - if ('_FillValue' in attrs and |
159 |
| - not utils.equivalent(attrs['_FillValue'], |
160 |
| - attrs['missing_value'])): |
161 |
| - raise ValueError("Conflicting _FillValue and missing_value " |
162 |
| - "attrs on a variable {!r}: {} vs. {}\n\n" |
163 |
| - "Consider opening the offending dataset " |
164 |
| - "using decode_cf=False, correcting the " |
165 |
| - "attrs and decoding explicitly using " |
166 |
| - "xarray.decode_cf()." |
167 |
| - .format(name, attrs['_FillValue'], |
168 |
| - attrs['missing_value'])) |
169 |
| - attrs['_FillValue'] = attrs.pop('missing_value') |
170 |
| - |
171 |
| - if '_FillValue' in attrs: |
172 |
| - raw_fill_value = pop_to(attrs, encoding, '_FillValue', name=name) |
173 |
| - encoded_fill_values = [ |
174 |
| - fv for fv in np.ravel(raw_fill_value) if not pd.isnull(fv)] |
| 155 | + raw_fill_values = [pop_to(attrs, encoding, attr, name=name) |
| 156 | + for attr in ('missing_value', '_FillValue')] |
| 157 | + if raw_fill_values: |
| 158 | + encoded_fill_values = [fv for option in raw_fill_values |
| 159 | + for fv in np.ravel(option) |
| 160 | + if not pd.isnull(fv)] |
175 | 161 |
|
176 | 162 | if len(encoded_fill_values) > 1:
|
177 | 163 | warnings.warn("variable {!r} has multiple fill values {}, "
|
|
0 commit comments