(self)
Trigger an update of point sizes

        The method calls `self.get_sizes`, which in turn calls the widget's
        `get_size_data`. The result are properly scaled and then passed
        back to widget for imputing (`master.impute_sizes`).
Trigger an update of point sizes
Trigger an update of point sizes
def update_sizes(self):
        """
        Trigger an update of point sizes

        The method calls `self.get_sizes`, which in turn calls the widget's
        `get_size_data`. The result are properly scaled and then passed
        back to widget for imputing (`master.impute_sizes`).
        """
        if self.scatterplot_item:
            size_data = self.get_sizes()
            size_imputer = getattr(
                self.master, "impute_sizes", self.default_impute_sizes)
            size_imputer(size_data)

            if self.timer is not None and self.timer.isActive():
                self.timer.stop()
                self.timer = None

            current_size_data = self.scatterplot_item.data["size"].copy()
            diff = size_data - current_size_data
            widget = self

            class Timeout:
                # 0.5 - np.cos(np.arange(0.17, 1, 0.09) * np.pi) / 2
                factors = [0.07, 0.16, 0.27, 0.41, 0.55,
                           0.68, 0.81, 0.9, 0.97, 1]

                def __init__(self):
                    self._counter = 0

                def __call__(self):
                    factor = self.factors[self._counter]
                    self._counter += 1
                    size = current_size_data + diff * factor
                    if len(self.factors) == self._counter:
                        widget.timer.stop()
                        widget.timer = None
                        size = size_data
                    widget.scatterplot_item.setSize(size)
                    widget.scatterplot_item_sel.setSize(size + SELECTION_WIDTH)
                    if widget.timer is None:
                        widget.end_resizing.emit()
                    else:
                        widget.step_resizing.emit()

            if self.n_valid <= MAX_N_VALID_SIZE_ANIMATE and \
                    np.all(current_size_data > 0) and np.any(diff != 0):
                # If encountered any strange behaviour when updating sizes,
                # implement it with threads
                self.begin_resizing.emit()
                interval = int(500 / len(Timeout.factors))
                self.timer = QTimer(self.scatterplot_item, interval=interval)
                self.timer.timeout.connect(Timeout())
                self.timer.start()
            else:
                self.begin_resizing.emit()
                self.scatterplot_item.setSize(size_data)
                self.scatterplot_item_sel.setSize(size_data + SELECTION_WIDTH)
                self.end_resizing.emit()
def update_sizes ( self ) : if self . scatterplot_item : size_data = self . get_sizes ( ) size_imputer = getattr ( self . master , "impute_sizes" , self . default_impute_sizes ) size_imputer ( size_data ) if self . timer is not None and self . timer . isActive ( ) : self . timer . stop ( ) self . timer = None current_size_data = self . scatterplot_item . data [ "size" ] . copy ( ) diff = size_data - current_size_data widget = self class Timeout : # 0.5 - np.cos(np.arange(0.17, 1, 0.09) * np.pi) / 2 factors = [ 0.07 , 0.16 , 0.27 , 0.41 , 0.55 , 0.68 , 0.81 , 0.9 , 0.97 , 1 ] def __init__ ( self ) : self . _counter = 0 def __call__ ( self ) : factor = self . factors [ self . _counter ] self . _counter += 1 size = current_size_data + diff * factor if len ( self . factors ) == self . _counter : widget . timer . stop ( ) widget . timer = None size = size_data widget . scatterplot_item . setSize ( size ) widget . scatterplot_item_sel . setSize ( size + SELECTION_WIDTH ) if widget . timer is None : widget . end_resizing . emit ( ) else : widget . step_resizing . emit ( ) if self . n_valid <= MAX_N_VALID_SIZE_ANIMATE and np . all ( current_size_data > 0 ) and np . any ( diff != 0 ) : # If encountered any strange behaviour when updating sizes, # implement it with threads self . begin_resizing . emit ( ) interval = int ( 500 / len ( Timeout . factors ) ) self . timer = QTimer ( self . scatterplot_item , interval = interval ) self . timer . timeout . connect ( Timeout ( ) ) self . timer . start ( ) else : self . begin_resizing . emit ( ) self . scatterplot_item . setSize ( size_data ) self . scatterplot_item_sel . setSize ( size_data + SELECTION_WIDTH ) self . end_resizing . emit ( )