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

Method encode

xarray/backends/common.py:438–471  ·  view source on GitHub ↗

Encode the variables and attributes in this store Parameters ---------- variables : dict-like Dictionary of key/value (variable name / xr.Variable) pairs attributes : dict-like Dictionary of key/value (attribute name / attribute) pair

(self, variables, attributes)

Source from the content-addressed store, hash-verified

436 __slots__ = ()
437
438 def encode(self, variables, attributes):
439 """
440 Encode the variables and attributes in this store
441
442 Parameters
443 ----------
444 variables : dict-like
445 Dictionary of key/value (variable name / xr.Variable) pairs
446 attributes : dict-like
447 Dictionary of key/value (attribute name / attribute) pairs
448
449 Returns
450 -------
451 variables : dict-like
452 attributes : dict-like
453
454 """
455 encoded_variables = {}
456 for k, v in variables.items():
457 try:
458 encoded_variables[k] = self.encode_variable(v)
459 except Exception as e:
460 e.add_note(f"Raised while encoding variable {k!r} with value {v!r}")
461 raise
462
463 encoded_attributes = {}
464 for k, v in attributes.items():
465 try:
466 encoded_attributes[k] = self.encode_attribute(v)
467 except Exception as e:
468 e.add_note(f"Raised while encoding attribute {k!r} with value {v!r}")
469 raise
470
471 return encoded_variables, encoded_attributes
472
473 def encode_variable(self, v, name=None):
474 """encode one variable"""

Callers 1

storeMethod · 0.95

Calls 3

encode_variableMethod · 0.95
encode_attributeMethod · 0.95
itemsMethod · 0.80

Tested by

no test coverage detected