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

Function dataset_merge_method

xarray/structure/merge.py:1148–1191  ·  view source on GitHub ↗

Guts of the Dataset.merge method.

(
    dataset: Dataset,
    other: CoercibleMapping,
    overwrite_vars: Hashable | Iterable[Hashable],
    compat: CompatOptions | CombineKwargDefault,
    join: JoinOptions | CombineKwargDefault,
    fill_value: Any,
    combine_attrs: CombineAttrsOptions,
)

Source from the content-addressed store, hash-verified

1146
1147
1148def dataset_merge_method(
1149 dataset: Dataset,
1150 other: CoercibleMapping,
1151 overwrite_vars: Hashable | Iterable[Hashable],
1152 compat: CompatOptions | CombineKwargDefault,
1153 join: JoinOptions | CombineKwargDefault,
1154 fill_value: Any,
1155 combine_attrs: CombineAttrsOptions,
1156) -> _MergeResult:
1157 """Guts of the Dataset.merge method."""
1158 # we are locked into supporting overwrite_vars for the Dataset.merge
1159 # method due for backwards compatibility
1160 # TODO: consider deprecating it?
1161
1162 if not isinstance(overwrite_vars, str) and isinstance(overwrite_vars, Iterable):
1163 overwrite_vars = set(overwrite_vars)
1164 else:
1165 overwrite_vars = {overwrite_vars}
1166
1167 if not overwrite_vars:
1168 objs = [dataset, other]
1169 priority_arg = None
1170 elif overwrite_vars == set(other):
1171 objs = [dataset, other]
1172 priority_arg = 1
1173 else:
1174 other_overwrite: dict[Hashable, CoercibleValue] = {}
1175 other_no_overwrite: dict[Hashable, CoercibleValue] = {}
1176 for k, v in other.items():
1177 if k in overwrite_vars:
1178 other_overwrite[k] = v
1179 else:
1180 other_no_overwrite[k] = v
1181 objs = [dataset, other_no_overwrite, other_overwrite]
1182 priority_arg = 2
1183
1184 return merge_core(
1185 objs,
1186 compat=compat,
1187 join=join,
1188 priority_arg=priority_arg,
1189 fill_value=fill_value,
1190 combine_attrs=combine_attrs,
1191 )
1192
1193
1194def dataset_update_method(dataset: Dataset, other: CoercibleMapping) -> _MergeResult:

Callers 1

mergeMethod · 0.90

Calls 2

merge_coreFunction · 0.85
itemsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…