Best Python code snippet using avocado_python
spark.py
Source:spark.py  
...486            rule = c[2]487            choices.append(rule)488            rule2cause[rule] = c489        return rule2cause[self.ambiguity(choices)]490    def deriveEpsilon(self, nt):491        if len(self.newrules[nt]) > 1:492            rule = self.ambiguity(self.newrules[nt])493        else:494            rule = self.newrules[nt][0]495        #print rule496        rhs = rule[1]497        attr = [None] * len(rhs)498        for i in xrange(len(rhs)-1, -1, -1):499            attr[i] = self.deriveEpsilon(rhs[i])500        return self.rule2func[self.new2old[rule]](attr)501    def buildTree(self, nt, item, tokens, k):502        state, parent = item503        choices = []504        for rule in self.states[state].complete:505            if rule[0] == nt:506                choices.append(rule)507        rule = choices[0]508        if len(choices) > 1:509            rule = self.ambiguity(choices)510        #print rule511        rhs = rule[1]512        attr = [None] * len(rhs)513        for i in xrange(len(rhs)-1, -1, -1):514            sym = rhs[i]515            if not self.newrules.has_key(sym):516                if sym != self._BOF:517                    attr[i] = tokens[k-1]518                    key = (item, k)519                    item, k = self.predecessor(key, None)520            #elif self.isnullable(sym):521            elif self._NULLABLE == sym[0:len(self._NULLABLE)]:522                attr[i] = self.deriveEpsilon(sym)523            else:524                key = (item, k)525                why = self.causal(key)526                attr[i] = self.buildTree(sym, why[0],527                            tokens, why[1])528                item, k = self.predecessor(key, why)529        return self.rule2func[self.new2old[rule]](attr)530    def ambiguity(self, rules):531        #532        #  XXX - problem here and in collectRules() if the same rule533        #	 appears in >1 method.  Also undefined results if rules534        #	 causing the ambiguity appear in the same method.535        #536        ...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
