Extract the priority variable from a list of mappings. We need this method because in some cases the priority argument itself might have conflicting values (e.g., if it is a dict with two DataArray values with conflicting coordinate values). Parameters ---------- objects :
(
objects: Sequence[DatasetLike],
priority_arg: int | None,
compat: CompatOptions | CombineKwargDefault = "equals",
)
| 544 | |
| 545 | |
| 546 | def _get_priority_vars_and_indexes( |
| 547 | objects: Sequence[DatasetLike], |
| 548 | priority_arg: int | None, |
| 549 | compat: CompatOptions | CombineKwargDefault = "equals", |
| 550 | ) -> dict[Hashable, MergeElement]: |
| 551 | """Extract the priority variable from a list of mappings. |
| 552 | |
| 553 | We need this method because in some cases the priority argument itself |
| 554 | might have conflicting values (e.g., if it is a dict with two DataArray |
| 555 | values with conflicting coordinate values). |
| 556 | |
| 557 | Parameters |
| 558 | ---------- |
| 559 | objects : sequence of dict-like of Variable |
| 560 | Dictionaries in which to find the priority variables. |
| 561 | priority_arg : int or None |
| 562 | Integer object whose variable should take priority. |
| 563 | compat : {"identical", "equals", "broadcast_equals", "no_conflicts", "override"}, optional |
| 564 | String indicating how to compare non-concatenated variables of the same name for |
| 565 | potential conflicts. This is passed down to merge. |
| 566 | |
| 567 | - "broadcast_equals": all values must be equal when variables are |
| 568 | broadcast against each other to ensure common dimensions. |
| 569 | - "equals": all values and dimensions must be the same. |
| 570 | - "identical": all values, dimensions and attributes must be the |
| 571 | same. |
| 572 | - "no_conflicts": only values which are not null in both datasets |
| 573 | must be equal. The returned dataset then contains the combination |
| 574 | of all non-null values. |
| 575 | - "override": skip comparing and pick variable from first dataset |
| 576 | |
| 577 | Returns |
| 578 | ------- |
| 579 | A dictionary of variables and associated indexes (if any) to prioritize. |
| 580 | """ |
| 581 | if priority_arg is None: |
| 582 | return {} |
| 583 | |
| 584 | collected = collect_variables_and_indexes([objects[priority_arg]]) |
| 585 | variables, indexes = merge_collected(collected, compat=compat) |
| 586 | grouped: dict[Hashable, MergeElement] = {} |
| 587 | for name, variable in variables.items(): |
| 588 | grouped[name] = (variable, indexes.get(name)) |
| 589 | return grouped |
| 590 | |
| 591 | |
| 592 | def merge_coords( |
no test coverage detected
searching dependent graphs…