Repository: matplotlib/matplotlib
File: lib/matplotlib/widgets.py (Python)

Code before:
            self._observers.process("changed", (vmin, vmax))

    def on_changed(self, func):
        """
        Connect *func* as callback function to changes of the slider value.

        Parameters
        ----------
        func : callable
            Function to call when slider is changed. The function
            must accept a 2-tuple of floats as its argument.

        Returns
        -------
        int
            Connection id (which can be used to disconnect *func*).
        """
        return self._observers.connect('changed', lambda val: func(val))


def _expand_text_props(props):
    props = cbook.normalize_kwargs(props, mtext.Text)
    return cycler(**props)() if props else itertools.repeat({})


class _Buttons(AxesWidget):

    def __init__(self, ax, labels, *, useblit=True, label_props=None, **kwargs):
        super().__init__(ax)

        ax.set_xticks([])
        ax.set_yticks([])
        ax.set_navigate(False)

        self._useblit = useblit

        self._buttons_ys = np.linspace(1, 0, len(labels)+2)[1:-1]

        label_props = _expand_text_props(label_props)

        self.labels = [
            ax.text(0.25, y, label, transform=ax.transAxes,
                    horizontalalignment="left", verticalalignment="center",
                    **props)
            for y, label, props in zip(self._buttons_ys, labels, label_props)]
        text_size = np.array([text.get_fontsize() for text in self.labels]) / 2

        self._init_props(text_size, **kwargs)

        self.connect_event('button_press_event', self._clicked)
        if self._useblit:

Review comment (suggestion):
Please add a docstring.

The class should be treated analogous to `_SelectorWidget`, including

> The class itself is private and may be changed or removed without prior warning.
> However, the public API it provides to subclasses is stable and considered
> public on the subclasses.

Code after:
            self._observers.process("changed", (vmin, vmax))

    def on_changed(self, func):
        """
        Connect *func* as callback function to changes of the slider value.

        Parameters
        ----------
        func : callable
            Function to call when slider is changed. The function
            must accept a 2-tuple of floats as its argument.

        Returns
        -------
        int
            Connection id (which can be used to disconnect *func*).
        """
        return self._observers.connect('changed', lambda val: func(val))


def _expand_text_props(props):
    props = cbook.normalize_kwargs(props, mtext.Text)
    return cycler(**props)() if props else itertools.repeat({})


class _Buttons(AxesWidget):
    """
    The base class for `CheckButtons` and `RadioButtons`.

    This class provides common functionality for button widgets,
    such as handling click events, managing button labels, and connecting callbacks.

    The class itself is private and may be changed or removed without prior warning.
    However, the public API it provides to subclasses is stable and considered
    public on the subclasses.
    """

    def __init__(self, ax, labels, *, useblit=True, label_props=None, **kwargs):
        super().__init__(ax)

        ax.set_xticks([])
        ax.set_yticks([])
        ax.set_navigate(False)

        self._useblit = useblit

        self._buttons_ys = np.linspace(1, 0, len(labels)+2)[1:-1]

        label_props = _expand_text_props(label_props)

        self.labels = [