

def _call_udf(self, method_name, **kwargs):
    '\n        Call a user-defined function stored in the _custom_functions dict\n\n        Parameters\n        ----------\n        method_name : str\n           The name of the user-defined method to setup a dispatch for\n        **kwargs : dict\n           Custom settings to pass to the UDF if they are requested by name\n           as input arguments\n\n        Returns\n        -------\n        The result of the UDF\n\n        Notes\n        -----\n        This function builds the necessary arguments to the\n        user-defined function. It also attempts to monitor\n        the state of the matplotlib plot, removing stale\n        artists and re-rendering the cavnas as needed.\n        '
    try:
        func = self._custom_functions[method_name]
    except KeyError:
        return []
    if self.remove_artists:
        layer = kwargs.get('layer', None)
        key = (layer, method_name)
        old = self._created_artists.get(key, set())
        remove_artists(old)
        current = all_artists(self.axes.figure)
    kwargs.setdefault('_self', self)
    kwargs.setdefault('axes', self.axes)
    kwargs.setdefault('figure', self.axes.figure)
    kwargs.setdefault('state', self.state)
    settings = SettingsOracle(self._settings, **kwargs)
    result = introspect_and_call(func, settings)
    if self.remove_artists:
        new = new_artists(self.axes.figure, current)
        self._created_artists[key] = new
        if current:
            self.axes.figure.canvas.draw()
    else:
        self.axes.figure.canvas.draw()
    return result

dataset/ETHPy150Open glue-viz/glue/glue/viewers/custom/qt/custom_viewer.py CustomViewer._call_udf/VarMisuse@194/466 `new`->`current`