Skip to content

Commit 5249814

Browse files
committed
Rename ordered_dict_union -> compat_dict_union
Do not use OrderedDicts any more, so name did not make sense.
1 parent 23df58e commit 5249814

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

xarray/core/merge.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from . import dtypes, pdcompat
2121
from .alignment import deep_align
2222
from .duck_array_ops import lazy_array_equiv
23-
from .utils import Frozen, dict_equiv, ordered_dict_union
23+
from .utils import Frozen, compat_dict_union, dict_equiv
2424
from .variable import Variable, as_variable, assert_unique_multiindex_level_names
2525

2626
if TYPE_CHECKING:
@@ -506,7 +506,7 @@ def merge_attrs(variable_attrs, combine_attrs):
506506
result = dict(variable_attrs[0])
507507
for attrs in variable_attrs[1:]:
508508
try:
509-
result = ordered_dict_union(result, attrs)
509+
result = compat_dict_union(result, attrs)
510510
except ValueError:
511511
raise MergeError(
512512
"combine_attrs='no_conflicts', but some values are not "

xarray/core/utils.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@ def ordered_dict_intersection(
361361
Binary operator to determine if two values are compatible. By default,
362362
checks for equivalence.
363363
364+
# TODO: Rename to compat_dict_intersection, as we do not use OrderedDicts
365+
# any more.
366+
364367
Returns
365368
-------
366369
intersection : dict
@@ -371,15 +374,15 @@ def ordered_dict_intersection(
371374
return new_dict
372375

373376

374-
def ordered_dict_union(
377+
def compat_dict_union(
375378
first_dict: Mapping[K, V],
376379
second_dict: Mapping[K, V],
377380
compat: Callable[[V, V], bool] = equivalent,
378381
) -> MutableMapping[K, V]:
379382
"""Return the union of two dictionaries as a new dictionary.
380383
381-
An exception is raised if any keys are found in both dictionaries and the values are
382-
not compatible.
384+
An exception is raised if any keys are found in both dictionaries and the
385+
values are not compatible.
383386
384387
Parameters
385388
----------

xarray/tests/test_utils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,16 @@ def test_ordered_dict_intersection(self):
124124
assert {"b": "B"} == utils.ordered_dict_intersection(self.x, self.y)
125125
assert {} == utils.ordered_dict_intersection(self.x, self.z)
126126

127-
def test_ordered_dict_union(self):
128-
assert {"a": "A", "b": "B", "c": "C"} == utils.ordered_dict_union(
127+
def test_compat_dict_union(self):
128+
assert {"a": "A", "b": "B", "c": "C"} == utils.compat_dict_union(
129129
self.x, self.y
130130
)
131131
with raises_regex(
132132
ValueError,
133133
"unsafe to merge dictionaries without "
134134
"overriding values; conflicting key",
135135
):
136-
utils.ordered_dict_union(self.x, self.z)
136+
utils.compat_dict_union(self.x, self.z)
137137

138138
def test_dict_equiv(self):
139139
x = {}

0 commit comments

Comments
 (0)