MCPcopy Create free account
hub / github.com/NSLS2/PyXRF / set_range

Method set_range

pyxrf/gui_module/useful_widgets.py:809–848  ·  view source on GitHub ↗

Set the full range of the RangeManager widget. The range may not be negative or zero: `low` must be strictly smaller than `high`. The `ValueError` is raised if `low >= high`. The function will not emit `selection_changed` signal. Call `emit_selection_changed()` metho

(self, low, high)

Source from the content-addressed store, hash-verified

807 return self.set_range(self._range_low, self._range_high)
808
809 def set_range(self, low, high):
810 """
811 Set the full range of the RangeManager widget. The range may not be negative or
812 zero: `low` must be strictly smaller than `high`. The `ValueError` is raised if
813 `low >= high`. The function will not emit `selection_changed` signal. Call
814 `emit_selection_changed()` method to emit the signal.
815
816 Parameters
817 ----------
818 low, high: float or int
819 lower and upper boundaries of the full range
820
821 Returns
822 -------
823 True - selected range was changed when full range was changed, False otherwise.
824 """
825 low, high = self._convert_type(low), self._convert_type(high)
826 # Check range
827 if low >= high:
828 raise ValueError(f"RangeManager.set_range(): incorrect range: low > high ({low} > {high})")
829
830 def _compute_new_value(val_old):
831 """
832 Adjust the current value so that the selected range covers the same
833 fraction of the total range.
834 """
835 range_old = self._range_high - self._range_low
836 range_new = high - low
837 return (val_old - self._range_low) / range_old * range_new + low
838
839 new_value_low = _compute_new_value(self._value_low)
840 new_value_high = _compute_new_value(self._value_high)
841
842 self._range_high = high
843 self._range_low = low
844
845 self._value_per_step = (self._range_high - self._range_low) / (self.sld_n_steps - 1)
846 self._range_min_diff = (self._range_high - self._range_low) * self._selection_to_range_min
847
848 return self.set_selection(value_low=new_value_low, value_high=new_value_high)
849
850 def set_selection(self, *, value_low=None, value_high=None):
851 """

Callers 15

fill_tableMethod · 0.95
set_value_typeMethod · 0.95
test_RangeManager_1Function · 0.95
test_RangeManager_2Function · 0.95
test_RangeManager_3Function · 0.95
test_RangeManager_4Function · 0.95
test_RangeManager_5Function · 0.95
test_RangeManager_7Function · 0.95
test_RangeManager_8Function · 0.95
test_RangeManager_9Function · 0.95
update_map_rangeMethod · 0.80
fill_tableMethod · 0.80

Calls 2

_convert_typeMethod · 0.95
set_selectionMethod · 0.95

Tested by 8

test_RangeManager_1Function · 0.76
test_RangeManager_2Function · 0.76
test_RangeManager_3Function · 0.76
test_RangeManager_4Function · 0.76
test_RangeManager_5Function · 0.76
test_RangeManager_7Function · 0.76
test_RangeManager_8Function · 0.76
test_RangeManager_9Function · 0.76