python - Compare Dictionaries for close enough match -


I'm looking for a good way to compare two dictionaries containing a matrix information. Therefore, the composition of my dictionaries is the following, both dictionaries have the same key:

  dict_1 = {("a", "a"): 0.01, ("a", "b") 0.02, ("a", "c"): 0.00015, ... dict_2 = {("a", "a"): 0.01, ("a", "b"): 0.018, ("a", " C "): 0.00014, ...  

If I have a matrix, that is, list list, I can use the numpy.allclose . Is there something similar for dictionaries or is it a good way to convert my matrix into such a matrix?

Thank you for your help.

The easiest way I could think:

  Keylist = dict_1.keys () array_1 = numpy.array (for key in key [dict_1 [key] key)) key in Array_2 = numpy.array keylist ([dict_2 [key]] if numpy.allclose (array_1, Array_2): print ('same') and: print ('not equal')  

Comments