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"])
| 45 | |
| 46 | |
| 47 | def 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 | |
| 79 | def comp_nums(num1, num2, tol=10e-8): |