(cls, palette, bins)
Construct a `BinnedPalette` from `ContinuousPalette` by picking the
        colors representing the centers of the bins.

        If given a `BinnedPalette`, the constructor returns a copy.

        Args:
            palette (ContinuousPalette or BinnedPalette): original palette
            bins (np.ndarray): bin boundaries
Construct a `BinnedPalette` from `ContinuousPalette` by picking the
        colors representing the centers of the bins.
Construct a BinnedPalette from ContinuousPalette by picking the colors representing the centers of the bins .
def from_palette(cls, palette, bins):
        """
        Construct a `BinnedPalette` from `ContinuousPalette` by picking the
        colors representing the centers of the bins.

        If given a `BinnedPalette`, the constructor returns a copy.

        Args:
            palette (ContinuousPalette or BinnedPalette): original palette
            bins (np.ndarray): bin boundaries
        """
        if isinstance(palette, cls):
            # Note that this silently ignores bins. This is done on purpose
            # to let predefined binned palettes override bins. Plus, it is
            # generally impossible to compute a binned palette with different
            # bins.
            return palette.copy()
        if isinstance(palette, ContinuousPalette):
            assert len(bins) >= 2
            mids = bins[:-1] / 2 + bins[1:] / 2
            bin_colors = palette.values_to_colors(mids, bins[0], bins[-1])
            return cls(
                palette.friendly_name, palette.name, bin_colors, bins,
                palette.nan_color, category=palette.category,
                flags=palette.flags | Palette.Discrete)
        raise TypeError(f"can't create palette from '{type(palette).__name__}'")
def from_palette ( cls , palette , bins ) : if isinstance ( palette , cls ) : # Note that this silently ignores bins. This is done on purpose # to let predefined binned palettes override bins. Plus, it is # generally impossible to compute a binned palette with different # bins. return palette . copy ( ) if isinstance ( palette , ContinuousPalette ) : assert len ( bins ) >= 2 mids = bins [ : - 1 ] / 2 + bins [ 1 : ] / 2 bin_colors = palette . values_to_colors ( mids , bins [ 0 ] , bins [ - 1 ] ) return cls ( palette . friendly_name , palette . name , bin_colors , bins , palette . nan_color , category = palette . category , flags = palette . flags | Palette . Discrete ) raise TypeError ( f"can't create palette from '{type(palette).__name__}'" )