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

Method encode

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

Source from the content-addressed store, hash-verified

686 """Encode Enum into variable dtype metadata."""
687
688 def encode(self, variable: Variable, name: T_Name = None) -> Variable:
689 if (
690 "dtype" in variable.encoding
691 and np.dtype(variable.encoding["dtype"]).metadata
692 and "enum" in variable.encoding["dtype"].metadata
693 ):
694 dims, data, attrs, encoding = unpack_for_encoding(variable)
695 data = data.astype(dtype=variable.encoding.pop("dtype"))
696 return Variable(dims, data, attrs, encoding, fastpath=True)
697 else:
698 return variable
699
700 def decode(self, variable: Variable, name: T_Name = None) -> Variable:
701 raise NotImplementedError()

Callers

nothing calls this directly

Calls 4

unpack_for_encodingFunction · 0.90
VariableClass · 0.90
dtypeMethod · 0.45
astypeMethod · 0.45

Tested by

no test coverage detected