MCPcopy
hub / github.com/pydata/xarray / apply_over_both

Method apply_over_both

xarray/core/dataset.py:7779–7796  ·  view source on GitHub ↗
(lhs_data_vars, rhs_data_vars, lhs_vars, rhs_vars)

Source from the content-addressed store, hash-verified

7777 self, f, other, join="inner", inplace: bool = False
7778 ) -> Dataset:
7779 def apply_over_both(lhs_data_vars, rhs_data_vars, lhs_vars, rhs_vars):
7780 if inplace and set(lhs_data_vars) != set(rhs_data_vars):
7781 raise ValueError(
7782 "datasets must have the same data variables "
7783 f"for in-place arithmetic operations: {list(lhs_data_vars)}, {list(rhs_data_vars)}"
7784 )
7785
7786 dest_vars = {}
7787
7788 for k in lhs_data_vars:
7789 if k in rhs_data_vars:
7790 dest_vars[k] = f(lhs_vars[k], rhs_vars[k])
7791 elif join in ["left", "outer"]:
7792 dest_vars[k] = f(lhs_vars[k], np.nan)
7793 for k in rhs_data_vars:
7794 if k not in dest_vars and join in ["right", "outer"]:
7795 dest_vars[k] = f(rhs_vars[k], np.nan)
7796 return dest_vars
7797
7798 if utils.is_dict_like(other) and not isinstance(other, Dataset):
7799 # can't use our shortcut of doing the binary operation with

Callers

nothing calls this directly

Calls 1

fFunction · 0.70

Tested by

no test coverage detected