|
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,22 @@ 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 | + raw_fill_values = [] |
155 | 156 | 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') |
| 157 | + missing = pop_to(attrs, encoding, 'missing_value', name=name) |
| 158 | + # Need to handle single and multiple values in 'missing_value' |
| 159 | + try: |
| 160 | + raw_fill_values.extend(missing) |
| 161 | + except TypeError: |
| 162 | + raw_fill_values.append(missing) |
170 | 163 |
|
171 | 164 | if '_FillValue' in attrs:
|
172 |
| - raw_fill_value = pop_to(attrs, encoding, '_FillValue', name=name) |
| 165 | + raw_fill_values.append(pop_to(attrs, encoding, '_FillValue', |
| 166 | + name=name)) |
| 167 | + |
| 168 | + if raw_fill_values: |
173 | 169 | encoded_fill_values = [
|
174 |
| - fv for fv in np.ravel(raw_fill_value) if not pd.isnull(fv)] |
| 170 | + fv for fv in np.ravel(raw_fill_values) if not pd.isnull(fv)] |
175 | 171 |
|
176 | 172 | if len(encoded_fill_values) > 1:
|
177 | 173 | warnings.warn("variable {!r} has multiple fill values {}, "
|
|
0 commit comments