MCPcopy
hub / github.com/pydata/xarray / _check_fill_values

Function _check_fill_values

xarray/coding/variables.py:167–200  ·  view source on GitHub ↗

Check _FillValue and missing_value if available. Return dictionary with raw fill values and set with encoded fill values. Issue SerializationWarning if appropriate.

(attrs, name, dtype)

Source from the content-addressed store, hash-verified

165
166
167def _check_fill_values(attrs, name, dtype):
168 """Check _FillValue and missing_value if available.
169
170 Return dictionary with raw fill values and set with encoded fill values.
171
172 Issue SerializationWarning if appropriate.
173 """
174 raw_fill_dict = {}
175 for attr in ("missing_value", "_FillValue"):
176 pop_to(attrs, raw_fill_dict, attr, name=name)
177 encoded_fill_values = set()
178 for k in list(raw_fill_dict):
179 v = raw_fill_dict[k]
180 kfill = {fv for fv in np.ravel(v) if not pd.isnull(fv)}
181 if not kfill and np.issubdtype(dtype, np.integer):
182 warnings.warn(
183 f"variable {name!r} has non-conforming {k!r} "
184 f"{v!r} defined, dropping {k!r} entirely.",
185 SerializationWarning,
186 stacklevel=3,
187 )
188 del raw_fill_dict[k]
189 else:
190 encoded_fill_values |= kfill
191
192 if len(encoded_fill_values) > 1:
193 warnings.warn(
194 f"variable {name!r} has multiple fill values "
195 f"{encoded_fill_values} defined, decoding all values to NaN.",
196 SerializationWarning,
197 stacklevel=3,
198 )
199
200 return raw_fill_dict, encoded_fill_values
201
202
203def _convert_unsigned_fill_value(

Callers 1

decodeMethod · 0.85

Calls 2

pop_toFunction · 0.90
isnullMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…