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

Function merge_coordinates_without_align

xarray/structure/merge.py:436–470  ·  view source on GitHub ↗

Merge variables/indexes from coordinates without automatic alignments. This function is used for merging coordinate from pre-existing xarray objects.

(
    objects: list[Coordinates],
    prioritized: Mapping[Any, MergeElement] | None = None,
    exclude_dims: AbstractSet = frozenset(),
    combine_attrs: CombineAttrsOptions = "override",
    compat: CompatOptions | CombineKwargDefault = "minimal",
)

Source from the content-addressed store, hash-verified

434
435
436def merge_coordinates_without_align(
437 objects: list[Coordinates],
438 prioritized: Mapping[Any, MergeElement] | None = None,
439 exclude_dims: AbstractSet = frozenset(),
440 combine_attrs: CombineAttrsOptions = "override",
441 compat: CompatOptions | CombineKwargDefault = "minimal",
442) -> tuple[dict[Hashable, Variable], dict[Hashable, Index]]:
443 """Merge variables/indexes from coordinates without automatic alignments.
444
445 This function is used for merging coordinate from pre-existing xarray
446 objects.
447 """
448 collected = collect_from_coordinates(objects)
449
450 if exclude_dims:
451 filtered: dict[Hashable, list[MergeElement]] = {}
452 for name, elements in collected.items():
453 new_elements = [
454 (variable, index)
455 for variable, index in elements
456 if exclude_dims.isdisjoint(variable.dims)
457 ]
458 if new_elements:
459 filtered[name] = new_elements
460 else:
461 filtered = collected
462
463 # TODO: indexes should probably be filtered in collected elements
464 # before merging them
465 merged_coords, merged_indexes = merge_collected(
466 filtered, prioritized, compat=compat, combine_attrs=combine_attrs
467 )
468 merged_indexes = filter_indexes_from_coords(merged_indexes, set(merged_coords))
469
470 return merged_coords, merged_indexes
471
472
473def determine_coords(

Callers 7

mapMethod · 0.90
_merge_rawMethod · 0.90
_merge_inplaceMethod · 0.90
mergeMethod · 0.90

Calls 4

collect_from_coordinatesFunction · 0.85
merge_collectedFunction · 0.85
itemsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…