MCPcopy Index your code
hub / github.com/plotly/plotly.py / compare_dict

Function compare_dict

tests/utils.py:15–44  ·  view source on GitHub ↗
(dict1, dict2, equivalent=True, msg="", tol=10e-8)

Source from the content-addressed store, hash-verified

13
14
15def compare_dict(dict1, dict2, equivalent=True, msg="", tol=10e-8):
16 for key in dict1:
17 if key not in dict2:
18 return (
19 False,
20 "{0} should be {1}".format(list(dict1.keys()), list(dict2.keys())),
21 )
22 for key in dict1:
23 if isinstance(dict1[key], dict):
24 equivalent, msg = compare_dict(dict1[key], dict2[key], tol=tol)
25 elif isinstance(dict1[key], Num) and isinstance(dict2[key], Num):
26 if not comp_nums(dict1[key], dict2[key], tol):
27 return (
28 False,
29 "['{0}'] = {1} should be {2}".format(key, dict1[key], dict2[key]),
30 )
31 elif is_num_list(dict1[key]) and is_num_list(dict2[key]):
32 if not comp_num_list(dict1[key], dict2[key], tol):
33 return (
34 False,
35 "['{0}'] = {1} should be {2}".format(key, dict1[key], dict2[key]),
36 )
37 elif not (dict1[key] == dict2[key]):
38 return (
39 False,
40 "['{0}'] = {1} should be {2}".format(key, dict1[key], dict2[key]),
41 )
42 if not equivalent:
43 return False, "['{0}']".format(key) + msg
44 return equivalent, msg
45
46
47def strip_dict_params(d1, d2, ignore=["uid"]):

Callers 10

test_annotationsFunction · 0.85
test_blank_subplotsFunction · 0.85
test_simple_scatterFunction · 0.85
test_double_scatterFunction · 0.85
test_vertical_barFunction · 0.85
test_horizontal_barFunction · 0.85
test_h_and_v_barsFunction · 0.85
test_even_linear_scaleFunction · 0.85
test_simple_lineFunction · 0.85
test_complicated_lineFunction · 0.85

Calls 5

comp_numsFunction · 0.85
is_num_listFunction · 0.85
comp_num_listFunction · 0.85
formatMethod · 0.45
keysMethod · 0.45

Tested by 10

test_annotationsFunction · 0.68
test_blank_subplotsFunction · 0.68
test_simple_scatterFunction · 0.68
test_double_scatterFunction · 0.68
test_vertical_barFunction · 0.68
test_horizontal_barFunction · 0.68
test_h_and_v_barsFunction · 0.68
test_even_linear_scaleFunction · 0.68
test_simple_lineFunction · 0.68
test_complicated_lineFunction · 0.68