def remove_comp(s): try: c = COMP_REGEX.findall(s)[0] s = s.split(c)[0] if s.startswith('not '): s = s[4:] return s except IndexError, e: return s
def remove_attr(s): """ return >10 where s=Ar40>10 """ try: c = COMP_REGEX.findall(s)[0] return '{}{}'.format(c, s.split(c)[-1]) except IndexError: return ''
def _selected_changed(self, new): if new: teststr = new.teststr with no_update(self): for a in TAGS.split(','): try: setattr(self, a, getattr(new, a)) except AttributeError: continue self.function = '' self.secondary_value = 0 self.value = 0 self.modifier = '' for r, a in ((CP_REGEX, 'Current'), (STD_REGEX, 'StdDev'), (ACTIVE_REGEX, 'Inactive'), (BASELINECOR_REGEX, 'BaselineCorrected'), (BASELINE_REGEX, 'Baseline')): if r.search(teststr): setattr(self, 'modifier', a) break for r, a in ((MAX_REGEX, 'Max'), (MIN_REGEX, 'Min'), (AVG_REGEX, 'Average'), (SLOPE_REGEX, 'Slope')): if r.search(teststr): setattr(self, 'function', a) break else: if BETWEEN_REGEX.search(teststr): self.function = 'Between' self.comparator = '' args = ARGS_REGEX.findall(teststr)[0][1:-1].split(',') self.value = float(args[1].strip()) self.secondary_value = float(args[2].strip()) # extract comparator m = COMP_REGEX.findall(teststr) if m: m1 = m[0] self.comparator = c = m1 self.value = float(teststr.split(c)[-1]) # extract use invert if teststr.startswith('not '): self.use_invert = True self._selected_changed_hook()
def _selected_changed(self, new): if new: teststr = new.teststr with no_update(self): for a in TAGS.split(','): try: setattr(self, a, getattr(new, a)) except (AttributeError, TraitError): continue self.function = '' self.secondary_value = 0 self.value = 0 self.modifier = '' for r, a in ((CP_REGEX, 'Current'), (STD_REGEX, 'StdDev'), (ACTIVE_REGEX, 'Inactive'), (BASELINECOR_REGEX, 'BaselineCorrected'), (BASELINE_REGEX, 'Baseline')): if r.search(teststr): setattr(self, 'modifier', a) break for r, a in ((MAX_REGEX, 'Max'), (MIN_REGEX, 'Min'), (AVG_REGEX, 'Average'), (SLOPE_REGEX, 'Slope')): if r.search(teststr): setattr(self, 'function', a) break else: if BETWEEN_REGEX.search(teststr): self.function = 'Between' self.comparator = '' args = ARGS_REGEX.findall(teststr)[0][1:-1].split(',') self.value = float(args[1].strip()) self.secondary_value = float(args[2].strip()) # extract comparator m = COMP_REGEX.findall(teststr) if m: m1 = m[0] self.comparator = c = m1 self.value = float(teststr.split(c)[-1]) # extract use invert if teststr.startswith('not '): self.use_invert = True self._selected_changed_hook()