MCPcopy Create free account
hub / github.com/pydata/xarray / _force_native_endianness

Function _force_native_endianness

xarray/backends/netCDF4_.py:232–252  ·  view source on GitHub ↗
(var)

Source from the content-addressed store, hash-verified

230
231
232def _force_native_endianness(var):
233 # possible values for byteorder are:
234 # = native
235 # < little-endian
236 # > big-endian
237 # | not applicable
238 # Below we check if the data type is not native or NA
239 if var.dtype.byteorder not in ["=", "|"]:
240 # if endianness is specified explicitly, convert to the native type
241 data = var.data.astype(var.dtype.newbyteorder("="))
242 var = Variable(var.dims, data, var.attrs, var.encoding)
243 # if endian exists, remove it from the encoding.
244 var.encoding.pop("endian", None)
245 # check to see if encoding has a value for endian its 'native'
246 if var.encoding.get("endian", "native") != "native":
247 raise NotImplementedError(
248 "Attempt to write non-native endian type, "
249 "this is not supported by the netCDF4 "
250 "python library."
251 )
252 return var
253
254
255def _extract_nc4_variable_encoding(

Callers 1

encode_variableMethod · 0.85

Calls 3

VariableClass · 0.90
astypeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…