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

Method _remove_overlapping_props

plotly/basewidget.py:806–881  ·  view source on GitHub ↗

Remove properties in input_data that are also in delta_data, and do so recursively. Exception: Never remove 'uid' from input_data, this property is used to align traces Parameters ---------- input_data : dict|list delta_data : dict|l

(input_data, delta_data, prop_path=())

Source from the content-addressed store, hash-verified

804 # --------------
805 @staticmethod
806 def _remove_overlapping_props(input_data, delta_data, prop_path=()):
807 """
808 Remove properties in input_data that are also in delta_data, and do so
809 recursively.
810
811 Exception: Never remove 'uid' from input_data, this property is used
812 to align traces
813
814 Parameters
815 ----------
816 input_data : dict|list
817 delta_data : dict|list
818
819 Returns
820 -------
821 list[tuple[str|int]]
822 List of removed property path tuples
823 """
824
825 # Initialize removed
826 # ------------------
827 # This is the list of path tuples to the properties that were
828 # removed from input_data
829 removed = []
830
831 # Handle dict
832 # -----------
833 if isinstance(input_data, dict):
834 assert isinstance(delta_data, dict)
835
836 for p, delta_val in delta_data.items():
837 if isinstance(delta_val, dict) or BaseFigure._is_dict_list(delta_val):
838 if p in input_data:
839 # ### Recurse ###
840 input_val = input_data[p]
841 recur_prop_path = prop_path + (p,)
842 recur_removed = BaseFigureWidget._remove_overlapping_props(
843 input_val, delta_val, recur_prop_path
844 )
845 removed.extend(recur_removed)
846
847 # Check whether the last property in input_val
848 # has been removed. If so, remove it entirely
849 if not input_val:
850 input_data.pop(p)
851 removed.append(recur_prop_path)
852
853 elif p in input_data and p != "uid":
854 # ### Remove property ###
855 input_data.pop(p)
856 removed.append(prop_path + (p,))
857
858 # Handle list
859 # -----------
860 elif isinstance(input_data, list):
861 assert isinstance(delta_data, list)
862
863 for i, delta_val in enumerate(delta_data):

Callers 2

Calls 4

_is_dict_listMethod · 0.80
itemsMethod · 0.45
extendMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected