MCPcopy Index your code
hub / github.com/pydata/xarray / encode

Method encode

xarray/coding/variables.py:585–597  ·  view source on GitHub ↗
(self, variable: Variable, name: T_Name = None)

Source from the content-addressed store, hash-verified

583 """Code boolean values."""
584
585 def encode(self, variable: Variable, name: T_Name = None) -> Variable:
586 if (
587 (variable.dtype == bool)
588 and ("dtype" not in variable.encoding)
589 and ("dtype" not in variable.attrs)
590 ):
591 dims, data, attrs, encoding = unpack_for_encoding(variable)
592 attrs["dtype"] = "bool"
593 data = duck_array_ops.astype(data, dtype="i1", copy=True)
594
595 return Variable(dims, data, attrs, encoding, fastpath=True)
596 else:
597 return variable
598
599 def decode(self, variable: Variable, name: T_Name = None) -> Variable:
600 if variable.attrs.get("dtype", False) == "bool":

Callers

nothing calls this directly

Calls 3

unpack_for_encodingFunction · 0.90
VariableClass · 0.90
astypeMethod · 0.45

Tested by

no test coverage detected