File tree 3 files changed +11
-8
lines changed
3 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 20
20
from . import dtypes , pdcompat
21
21
from .alignment import deep_align
22
22
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
24
24
from .variable import Variable , as_variable , assert_unique_multiindex_level_names
25
25
26
26
if TYPE_CHECKING :
@@ -506,7 +506,7 @@ def merge_attrs(variable_attrs, combine_attrs):
506
506
result = dict (variable_attrs [0 ])
507
507
for attrs in variable_attrs [1 :]:
508
508
try :
509
- result = ordered_dict_union (result , attrs )
509
+ result = compat_dict_union (result , attrs )
510
510
except ValueError :
511
511
raise MergeError (
512
512
"combine_attrs='no_conflicts', but some values are not "
Original file line number Diff line number Diff line change @@ -361,6 +361,9 @@ def ordered_dict_intersection(
361
361
Binary operator to determine if two values are compatible. By default,
362
362
checks for equivalence.
363
363
364
+ # TODO: Rename to compat_dict_intersection, as we do not use OrderedDicts
365
+ # any more.
366
+
364
367
Returns
365
368
-------
366
369
intersection : dict
@@ -371,15 +374,15 @@ def ordered_dict_intersection(
371
374
return new_dict
372
375
373
376
374
- def ordered_dict_union (
377
+ def compat_dict_union (
375
378
first_dict : Mapping [K , V ],
376
379
second_dict : Mapping [K , V ],
377
380
compat : Callable [[V , V ], bool ] = equivalent ,
378
381
) -> MutableMapping [K , V ]:
379
382
"""Return the union of two dictionaries as a new dictionary.
380
383
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.
383
386
384
387
Parameters
385
388
----------
Original file line number Diff line number Diff line change @@ -124,16 +124,16 @@ def test_ordered_dict_intersection(self):
124
124
assert {"b" : "B" } == utils .ordered_dict_intersection (self .x , self .y )
125
125
assert {} == utils .ordered_dict_intersection (self .x , self .z )
126
126
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 (
129
129
self .x , self .y
130
130
)
131
131
with raises_regex (
132
132
ValueError ,
133
133
"unsafe to merge dictionaries without "
134
134
"overriding values; conflicting key" ,
135
135
):
136
- utils .ordered_dict_union (self .x , self .z )
136
+ utils .compat_dict_union (self .x , self .z )
137
137
138
138
def test_dict_equiv (self ):
139
139
x = {}
You can’t perform that action at this time.
0 commit comments