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

Method encode

xarray/coding/strings.py:157–165  ·  view source on GitHub ↗
(self, variable, name=None)

Source from the content-addressed store, hash-verified

155 """Transforms between arrays containing bytes and character arrays."""
156
157 def encode(self, variable, name=None):
158 variable = ensure_fixed_length_bytes(variable)
159
160 dims, data, attrs, encoding = unpack_for_encoding(variable)
161 if data.dtype.kind == "S" and encoding.get("dtype") is not str:
162 data = bytes_to_char(data)
163 char_dim_name = validate_char_dim_name(data.shape[-1], encoding, name)
164 dims = dims + (char_dim_name,)
165 return Variable(dims, data, attrs, encoding)
166
167 def decode(self, variable, name=None):
168 dims, data, attrs, encoding = unpack_for_decoding(variable)

Calls 6

VariableClass · 0.90
unpack_for_encodingFunction · 0.85
bytes_to_charFunction · 0.85
validate_char_dim_nameFunction · 0.85
getMethod · 0.45