Extract a list of expressions from the dictionary of expressions.
511598
def update_expression_list(self):
        """"""
        self.expression_list = [] # code arrives in dictionary, but is passed in this list
        self.expression_keys = [] # Keep track of the dictionary keys.
        self.expression_order = [] # This may be unecessary. It's to give ordering for cse
        for fname, fexpressions in self.expressions.items():
            for type, texpressions in fexpressions.items():
                if type == 'function':
                    self.expression_list.append(texpressions)            
                    self.expression_keys.append([fname, type])
                    self.expression_order.append(1) 
                elif type[-10:] == 'derivative':
                    for dtype, expression in texpressions.items():
                        self.expression_list.append(expression)
                        self.expression_keys.append([fname, type, dtype])
                        if type[:-10] == 'first_' or type[:-10] == '':
                            self.expression_order.append(3) #sym.count_ops(self.expressions[type][dtype]))
                        elif type[:-10] == 'second_':
                            self.expression_order.append(4) #sym.count_ops(self.expressions[type][dtype]))
                        elif type[:-10] == 'third_':
                            self.expression_order.append(5) #sym.count_ops(self.expressions[type][dtype]))
                else:
                    self.expression_list.append(fexpressions[type])            
                    self.expression_keys.append([fname, type])
                    self.expression_order.append(2) 

        # This step may be unecessary.
        # Not 100% sure if the sub expression elimination is order sensitive. This step orders the list with the 'function' code first and derivatives after.
        self.expression_order, self.expression_list, self.expression_keys = zip(*sorted(zip(self.expression_order, self.expression_list, self.expression_keys)))
518058
def translate(self):
        
        expressions = []
        varnames = set()
        funcnames = set()
        for part in self.parts:
            if isinstance(part, str):
                expressions.append(ex_literal(part))
            else:
                e, v, f = part.translate()
                expressions.extend(e)
                varnames.update(v)
                funcnames.update(f)
        return expressions, varnames, funcnames
1255982
def _handle_expr_list(self, node, scope, ctxt, stream):
        
        self._dlog("handling expression list")
        exprs = [
            self._handle_node(expr, scope, ctxt, stream) for expr in node.exprs
        ]
        return exprs
99809
def in_query(expression):
    """"""
    def _in(index, expression=expression):
        """Return store key for documents that satisfy expression."""
        ev = expression() if callable(expression) else expression
        try:
            iter(ev)
        except TypeError:
            raise AttributeError('$in argument must be an iterable!')
        hashed_ev = [index.get_hash_for(v) for v in ev]
        store_keys = set()

        for value in hashed_ev:
            store_keys |= set(index.get_keys_for(value))

        return list(store_keys)

    return _in
1086548
def _extract_conjuction_elements_from_expression(expression):
    """"""
    if isinstance(expression, BinaryComposition) and expression.operator == u'&&':
        for element in _extract_conjuction_elements_from_expression(expression.left):
            yield element
        for element in _extract_conjuction_elements_from_expression(expression.right):
            yield element
    else:
        yield expression
326063
def child_expressions(self):
        
        expressions = [ ]
        for k in self.__slots__:
            v = getattr(self, k)
            if isinstance(v, IRExpr):
                expressions.append(v)
                expressions.extend(v.child_expressions)
        return expressions
1319483
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False):
        """"""
        c = self.copy()
        c.is_summary = summarize
        c.for_save = for_save
        for pos, expression in enumerate(self.expressions):
            c.expressions[pos] = expression.resolve_expression(query, allow_joins, reuse, summarize)
        return c
812761
def _ExtractList(self, fields, ignores=(",",), terminators=()):
    """"""
    extracted = []
    i = 0
    for i, field in enumerate(fields):
      # Space-separated comma; ignore, but this is not a finished list.
      # Similar for any other specified ignores (eg, equals sign).
      if field in ignores:
        continue

      # However, some fields are specifically meant to terminate iteration.
      if field in terminators:
        break

      extracted.append(field.strip("".join(ignores)))
      # Check for continuation; this will either be a trailing comma or the
      # next field after this one being a comma. The lookahead here is a bit
      # nasty.
      if not (field.endswith(",") or
              set(fields[i + 1:i + 2]).intersection(ignores)):
        break

    return extracted, fields[i + 1:]
85997
def findall(self, expr):
        
        result = []
        try:
            for arg in expr.args:
                result.extend(self.findall(arg))
            for arg in expr.kwargs.values():
                result.extend(self.findall(arg))
        except AttributeError:
            pass
        if self.match(expr):
            result.append(expr)
        return result
817194
def extract_params(params):
    
    values = []
    if isinstance(params, dict):
        for key, value in params.items():
            values.extend(extract_params(value))
    elif isinstance(params, list):
        for value in params:
            values.extend(extract_params(value))
    else:
        values.append(params)
    return values
859343
def extract_expression(dirty_string, language):
    
    tokens = tokenize(dirty_string, language)

    start_index = 0
    end_index = len(tokens)

    for part in tokens:
        if is_symbol(part) or is_word(part, language):
            break
        else:
            start_index += 1

    for part in reversed(tokens):
        if is_symbol(part) or is_word(part, language):
            break
        else:
            end_index -= 1

    return ' '.join(tokens[start_index:end_index])
323260
public Collection<Expression> expressions(ExpressionFilter filter) {
        return get(Expression.class, (filter != null) ? filter : new ExpressionFilter());
    }
233507
def _set_expressions(self, expressions):
        """"""
        self.expressions = {}
        for key, item in expressions.items():
            self.expressions[key] = {'function': item}
1044889
def extract_vars(template):
    
    keys = set()
    for match in re.finditer(r"\{\{ (?P<key>\w+) \}\}", template.getvalue()):
        keys.add(match.groups()[0])
    return sorted(list(keys))
641685
def regex_extract(arg, pattern, index):
    
    return ops.RegexExtract(arg, pattern, index).to_expr()
730786
def all_expressions(self):
        
        if self._all_expressions is None:
            self._all_expressions = self._explore_functions(lambda x: x.expressions)
        return self._all_expressions
708421
def extract_smiles(s):
    """"""
    # TODO: This still gets a lot of false positives.
    smiles = []
    for t in s.split():
        if len(t) > 2 and SMILES_RE.match(t) and not t.endswith('.') and bracket_level(t) == 0:
            smiles.append(t)
    return smiles