def test_parse_range_wavelength_dashes(self): wav_full_range, wav_pairs = parse_range_wavelength("2-5, 6-10") self.assertEqual((2., 10.), wav_full_range) self.assertEqual([(2., 5.), (6., 10.), (2., 10.)], wav_pairs) # Should also handle flipped wav_full_range, wav_pairs = parse_range_wavelength("6-10, 2-5") self.assertEqual((2., 10.), wav_full_range) self.assertEqual([(6., 10.), (2., 5.), (2., 10.)], wav_pairs)
def test_wavelength_multiple_commas(self): # This is a legacy input which isn't documented in the current GUI # but some scientists still use from the older SANS GUI # Equiv to 1-3, 3-5, 5-7, 7-11 wav_full_range, wav_pairs = parse_range_wavelength("1,3 ,5, 7,11") # Random spacing intentional self.assertEqual((1., 11.), wav_full_range) self.assertEqual([(1., 3.), (3., 5.), (5., 7.), (7., 11.), (1., 11.0)], wav_pairs)
def wavelength_range(self, value): full_range, pairs = parse_range_wavelength(value) self._set_on_all_wavelength("wavelength_full_range", full_range) self._set_on_all_wavelength('selected_ranges', pairs) # Ensure the GUI remembers the original user string self._wavelength_range = value
def test_parse_range_wavelength(self): wav_full_range, wav_pairs = parse_range_wavelength("2:2:10") # 2-10 in steps of 2 self.assertEqual((2.0, 10.0), wav_full_range) self.assertEqual([(2., 4.), (4., 6.), (6., 8.), (8., 10.), (2., 10.)], wav_pairs)