(self, number_of_colors=0)
Change the palette if there are palettes for different number of
           colors. Else, just copy colors as numpy array
Change the palette if there are palettes for different number of
           colors. Else, just copy colors as numpy array
Change the palette if there are palettes for different number of colors . Else just copy colors as numpy array
def set_number_of_colors(self, number_of_colors=0):
        """Change the palette if there are palettes for different number of
           colors. Else, just copy colors as numpy array"""
        self.number_of_colors = number_of_colors
        if isinstance(self.rgb_colors, dict):
            number_of_colors = max(3, number_of_colors)
            if number_of_colors not in self.rgb_colors:
                try:
                    number_of_colors = min([n for n in self.rgb_colors
                                            if n >= number_of_colors])
                except ValueError:
                    raise ValueError("Not enough colors")
            rgb_colors = self.rgb_colors[number_of_colors]
        elif number_of_colors <= len(self.rgb_colors):
            rgb_colors = self.rgb_colors
        else:
            rgb_colors = []
            for i in range(self.number_of_colors):
                col = QColor()
                col.setHsv(360 / number_of_colors * i, 255, 255)
                rgb_colors.append(col.getRgb()[:3])
        self.rgb_array = np.vstack((rgb_colors, [NAN_GREY])).astype(np.uint8)
def set_number_of_colors ( self , number_of_colors = 0 ) : self . number_of_colors = number_of_colors if isinstance ( self . rgb_colors , dict ) : number_of_colors = max ( 3 , number_of_colors ) if number_of_colors not in self . rgb_colors : try : number_of_colors = min ( [ n for n in self . rgb_colors if n >= number_of_colors ] ) except ValueError : raise ValueError ( "Not enough colors" ) rgb_colors = self . rgb_colors [ number_of_colors ] elif number_of_colors <= len ( self . rgb_colors ) : rgb_colors = self . rgb_colors else : rgb_colors = [ ] for i in range ( self . number_of_colors ) : col = QColor ( ) col . setHsv ( 360 / number_of_colors * i , 255 , 255 ) rgb_colors . append ( col . getRgb ( ) [ : 3 ] ) self . rgb_array = np . vstack ( ( rgb_colors , [ NAN_GREY ] ) ) . astype ( np . uint8 )