示例#1
0
 def test_scroll_log(self):
     min_val = 50
     max_val = 51
     for scroll_val in range(101):
         assert utils.scroll_linear(scroll_val, min_val, max_val) == \
                pytest.approx(10 ** (scroll_val * (np.log10(max_val) - np.log10(min_val)) / 100 + np.log10(min_val)),
                              rel=1e-4)
示例#2
0
    def update_spinbox(self, val):
        """
        val is a percentage [0-100] used in order to set the spinbox value between its min and max
        """
        min_val = float(self.opts['bounds'][0])
        max_val = float(self.opts['bounds'][1])
        if self.subtype == 'log':
            val_out = scroll_log(val, min_val, max_val)
        else:
            val_out = scroll_linear(val, min_val, max_val)
        try:
            self.slider.valueChanged.disconnect(self.update_spinbox)
            self.spinbox.valueChanged.disconnect(self.update_slide)
        except Exception:
            pass
        self.spinbox.setValue(val_out)

        self.slider.valueChanged.connect(self.update_spinbox)
        self.spinbox.valueChanged.connect(self.update_slide)
示例#3
0
 def test_scroll_linear(self):
     min_val = 50
     max_val = 51
     for scroll_val in range(101):
         assert utils.scroll_linear(scroll_val, min_val, max_val) == \
                pytest.approx(scroll_val * (max_val - min_val) / 100 + min_val)