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

Function strip_dict_params

tests/utils.py:47–76  ·  view source on GitHub ↗

Helper function for assert_dict_equal Nearly duplicate of assert_fig_equal in tests/test_optional/optional_utils.py Removes `ignore` params from d1 and/or d2 if they exist then returns stripped dictionaries :param (list|tuple) ignore: sequence of key names as strings t

(d1, d2, ignore=["uid"])

Source from the content-addressed store, hash-verified

45
46
47def strip_dict_params(d1, d2, ignore=["uid"]):
48 """
49 Helper function for assert_dict_equal
50
51 Nearly duplicate of assert_fig_equal in tests/test_optional/optional_utils.py
52 Removes `ignore` params from d1 and/or d2 if they exist
53 then returns stripped dictionaries
54
55 :param (list|tuple) ignore: sequence of key names as
56 strings that are removed from both d1 and d2 if
57 they exist
58 """
59 # deep copy d1 and d2
60 if "to_plotly_json" in dir(d1):
61 d1_copy = copy.deepcopy(d1.to_plotly_json())
62 else:
63 d1_copy = copy.deepcopy(d1)
64
65 if "to_plotly_json" in dir(d2):
66 d2_copy = copy.deepcopy(d2.to_plotly_json())
67 else:
68 d2_copy = copy.deepcopy(d2)
69
70 for key in ignore:
71 if key in d1_copy.keys():
72 del d1_copy[key]
73 if key in d2_copy.keys():
74 del d2_copy[key]
75
76 return d1_copy, d2_copy
77
78
79def comp_nums(num1, num2, tol=10e-8):

Callers 15

test_update_listMethod · 0.85
test_append_scatterFunction · 0.85
test_append_scatter3dFunction · 0.85
setUpMethod · 0.85
test_toplevel_attrMethod · 0.85
test_toplevel_itemMethod · 0.85
test_nested_attrMethod · 0.85
test_nested_itemMethod · 0.85
test_nested_item_dotsMethod · 0.85

Calls 2

to_plotly_jsonMethod · 0.45
keysMethod · 0.45

Tested by 15

test_update_listMethod · 0.68
test_append_scatterFunction · 0.68
test_append_scatter3dFunction · 0.68
setUpMethod · 0.68
test_toplevel_attrMethod · 0.68
test_toplevel_itemMethod · 0.68
test_nested_attrMethod · 0.68
test_nested_itemMethod · 0.68
test_nested_item_dotsMethod · 0.68