mirror of
https://github.com/3b1b/manim.git
synced 2025-09-19 04:41:56 +00:00
Add dict_eq
This commit is contained in:
parent
93e65fa3e7
commit
d9c85aac46
1 changed files with 17 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
import itertools as it
|
||||
import numpy as np
|
||||
|
||||
|
||||
def merge_dicts_recursively(*dicts):
|
||||
|
@ -29,3 +30,19 @@ def soft_dict_update(d1, d2):
|
|||
for key, value in list(d2.items()):
|
||||
if key not in d1:
|
||||
d1[key] = value
|
||||
|
||||
|
||||
def dict_eq(d1, d2):
|
||||
if len(d1) != len(d2):
|
||||
return False
|
||||
for key in d1:
|
||||
value1 = d1[key]
|
||||
value2 = d2[key]
|
||||
if type(value1) != type(value2):
|
||||
return False
|
||||
if type(d1[key]) == np.ndarray:
|
||||
if any(d1[key] != d2[key]):
|
||||
return False
|
||||
elif d1[key] != d2[key]:
|
||||
return False
|
||||
return True
|
||||
|
|
Loading…
Add table
Reference in a new issue