Test equivalence of two dict-like objects. If any of the values are numpy arrays, compare them correctly. Parameters ---------- first, second : dict-like Dictionaries to compare for equality compat : function, optional Binary operator to determine if two values a
(
first: Mapping[K, V],
second: Mapping[K, V],
compat: Callable[[V, V], bool] = equivalent,
)
| 408 | |
| 409 | |
| 410 | def dict_equiv( |
| 411 | first: Mapping[K, V], |
| 412 | second: Mapping[K, V], |
| 413 | compat: Callable[[V, V], bool] = equivalent, |
| 414 | ) -> bool: |
| 415 | """Test equivalence of two dict-like objects. If any of the values are |
| 416 | numpy arrays, compare them correctly. |
| 417 | |
| 418 | Parameters |
| 419 | ---------- |
| 420 | first, second : dict-like |
| 421 | Dictionaries to compare for equality |
| 422 | compat : function, optional |
| 423 | Binary operator to determine if two values are compatible. By default, |
| 424 | checks for equivalence. |
| 425 | |
| 426 | Returns |
| 427 | ------- |
| 428 | equals : bool |
| 429 | True if the dictionaries are equal |
| 430 | """ |
| 431 | for k in first: |
| 432 | if k not in second or not compat(first[k], second[k]): |
| 433 | return False |
| 434 | return all(k in first for k in second) |
| 435 | |
| 436 | |
| 437 | def compat_dict_intersection( |
no outgoing calls
no test coverage detected
searching dependent graphs…