Finds a generator as a statement
186586
def find_generator_as_statement(node):
    """"""
    return (
        isinstance(node, ast.Expr)
        and isinstance(node.value, ast.GeneratorExp)
    )
540313
def <<(statement)
      # ActiveTriples::Resource expects: RDF::Statement, Hash, or Array
      statement = RDF::Statement.from(statement) unless statement.is_a? RDF::Statement

      # Only push statement if the statement's predicate is defined on the class
      field_name = field_from_predicate(statement.predicate)
      return unless field_name

      objects = statement.object.is_a?(RDF::Node) && block_given? ? yield : statement.object

      update_field(field_name, *objects) if fields[field_name]
      update_relation(field_name, *objects) if relations[field_name]
    end
464751
def maybe_a(generator):
    

    class MaybeAGenerator(ArbitraryInterface):
        """
        A closure class around the generator specified above, which generates
        either that generator or None.
        """

        @classmethod
        def arbitrary(cls):
            """
            Generate either the enclosed generator or None.
            """
            return arbitrary(one_of(None, generator))

    MaybeAGenerator.__name__ = ''.join(['maybe_a(', generator.__name__, ')'])
    return MaybeAGenerator
1302913
def assign(self, expr):
        """"""
        name = self.variable()
        self.statements.append(ast.Assign([ast.Name(name, ast.Store())], expr))
        return ast.Name(name, ast.Load())
1302209
public ParseTree getStatementAtLine( int iLineNum, Class clsSkip )
  {
    if( _pe instanceof NewExpression )
    {
      NewExpression newExpression = (NewExpression)_pe;
      IType type = newExpression.getType();
      if( type instanceof IGosuClassInternal && newExpression.isAnonymousClass() )
      {
        return (ParseTree)((IGosuClassInternal)type).getClassStatement().getLocation().getStatementAtLine( iLineNum, clsSkip );
      }
    }

    if( (_pe instanceof Statement) && // Note we must analyze expressions e.g., block expressions can have statements
        !(_pe instanceof FunctionStatement && ((FunctionStatement)_pe).getDynamicFunctionSymbol() instanceof ProgramClassFunctionSymbol) &&
        (getLineNum() == iLineNum) &&
        (clsSkip == null || !clsSkip.isAssignableFrom( _pe.getClass() )) )
    {
      return this;
    }

    ParseTree deepest = null;
    for(int i = 0; i < _children.size; i++)
    {
      ParseTree child = (ParseTree) _children.data[i];
      ParseTree l = child.getStatementAtLine( iLineNum, clsSkip );
      if( Search.isDeeper( deepest, l ) )
      {
        deepest = l;
      }
    }

    return deepest;
  }
353708
def visit_yieldfrom(self, node):
        
        yi_val = (" " + node.value.accept(self)) if node.value else ""
        expr = "yield from" + yi_val
        if node.parent.is_statement:
            return expr

        return "(%s)" % (expr,)
565724
public function find()
    {
        foreach ($this->file->tokens as $i => $t) {
            if (TokenUtils::isTokenType($t, array(T_NEW))) {
                // +2 to consume whitespace
                $c = self::findClassInNextTokens($this->file->tokens, $i + 2);
                if ($c) {
                    yield $c;
                }
            } elseif (TokenUtils::isTokenType($t, array(T_IMPLEMENTS, T_EXTENDS))) {
                // +2 to consume whitespace
                $c = self::findClassInNextTokens($this->file->tokens, $i + 2);
                if ($c) {
                    yield $c;
                }
                $j = $c->to + 1;
                while ($this->file->tokens[$j] === ',') {
                    // +2 to consume comma and whitespace
                    $c = self::findClassInNextTokens($this->file->tokens, $j + 2);
                    if ($c) {
                        yield $c;
                        $j = $c->to;
                    }
                    $j++;
                }
            } elseif (TokenUtils::isTokenType($t, array(T_USE))) {
                $c = self::findClassInNextTokens($this->file->tokens, $i + 2);
                // Check if use statement is after class opening bracket
                if ($c && $this->isAfterOpeningBracket($c)) {
                    yield $c;
                }
            } elseif (TokenUtils::isTokenType($t, array(T_PAAMAYIM_NEKUDOTAYIM, T_DOUBLE_COLON))) {
                $c = self::findClassInPreviousTokens($this->file->tokens, $i - 1);
                if ($c) {
                    yield $c;
                }
            } elseif (TokenUtils::isTokenType($t, array(T_CATCH))) {
                // +3 to consume brace and whitespace
                $c = self::findClassInNextTokens($this->file->tokens, $i + 3);
                if ($c) {
                    yield $c;
                }
            } elseif (TokenUtils::isTokenType($t, array(T_INSTANCEOF))) {
                $c = self::findClassInNextTokens($this->file->tokens, $i + 2);
                if ($c) {
                    yield $c;
                }
            } elseif (TokenUtils::isTokenType($t, array(T_FUNCTION))) {
                $j = $i + 4;
                $j = TokenUtils::isTokenType($this->file->tokens[$j], T_WHITESPACE) ? $j + 1 : $j;

                // +4 to consume whitespace, name, open brace
                $c = self::findClassInNextTokens($this->file->tokens, $j);
                if ($c) {
                    yield $c;
                    $j = $c->to;
                }

                while ($this->file->tokens[$j] != ")") {
                    if ($this->file->tokens[$j] == ',') {
                        // +2 to consume comma and whitespace
                        $c = self::findClassInNextTokens($this->file->tokens, $j + 2);
                        if ($c) {
                            yield $c;
                            $j = $c->to;
                        }
                    }
                    $j++;
                }

            }
        }
    }
1298417
def p_iteration_statement_2(self, p):
        """"""
        p[0] = ast.While(predicate=p[3], statement=p[5])
594683
def p_iteration_statement_6(self, p):
        
        p[0] = ast.ForIn(item=ast.VarDecl(identifier=p[4], initializer=p[5]),
                         iterable=p[7], statement=p[9])
994148
function (statements, global) {
            var source = [];
            if (!global) {
                source.push('function(scopes) {');
            }
            source.push('var buffer = ""' + (global ? ',' : ';'));
            if (global) {
                source.push('config = this.config,' +
                    // current xtemplate engine
                    'engine = this, ' +
                    'utils = config.utils;');

                var natives = '',
                    c,
                    utils = XTemplateRuntime.utils;

                for (c in utils) {
                    natives += c + 'Util = utils["' + c + '"],';
                }

                if (natives) {
                    source.push('var ' + natives.slice(0, natives.length - 1) + ';');
                }
            }
            if (statements) {
                for (var i = 0, len = statements.length; i < len; i++) {
                    pushToArray(source, this[statements[i].type](statements[i]));
                }
            }
            source.push('return buffer;');
            if (!global) {
                source.push('}');
                return source;
            } else {
                return {
                    params: ['scopes', 'S', 'undefined'],
                    source: source
                };
            }
        }
1196407
def generator(self, t):
        """"""
        a = (np.exp(-self.theta * t) - 1) / (np.exp(-self.theta) - 1)
        return -np.log(a)
896935
def get_row_generator(self, ref, cache=None):

        """"""
        from inspect import isgenerator
        from rowgenerators import get_generator

        g = get_generator(ref)

        if not g:
            raise GenerateError("Cant figure out how to generate rows from {} ref: {}".format(type(ref), ref))
        else:
            return g
1342335
public static Statement getStatement(CompilationUnit compilationUnit, MethodDeclaration method, int startLine, int endLine)
            throws StatementNotFoundException {
        requireNonNull(compilationUnit, "compilation unit");
        requireNonNull(method, "method declaration");

        Statement statement = searchStatement(compilationUnit, method.getBody().statements(), startLine, endLine);
        if (statement == null) {
            throw new StatementNotFoundException(compilationUnit, startLine, endLine);
        }
        return statement;
    }
840758
def in_file(self, fn: str) -> Iterator[Statement]:
        
        yield from self.__file_to_statements.get(fn, [])
967245
function(name, options) {
        if (this.generators.hasOwnProperty(name)) {
          return this.generators[name];
        }

        if (~name.indexOf('.')) {
          return this.getSubGenerator.apply(this, arguments);
        }

        var opts = utils.extend({}, this.options, options);
        if (typeof opts.lookup === 'function') {
          var app = this.lookupGenerator(name, opts, opts.lookup);
          if (app) {
            return app;
          }
        }
        return this.matchGenerator(name);
      }
1098931
def visit_generatorexp(self, node):
        """"""
        return "(%s %s)" % (
            node.elt.accept(self),
            " ".join(n.accept(self) for n in node.generators),
        )
171275
def get_degenerate_statements(self):
        
        logger.info("Checking for 'degenerate' statements...\n")
        # Get rules of type protein X -> activity Y
        q_stmts = prefixes + """
            SELECT ?stmt
            WHERE {
                ?stmt a belvoc:Statement .
                ?stmt belvoc:hasSubject ?subj .
                ?stmt belvoc:hasObject ?obj .
                {
                  { ?stmt belvoc:hasRelationship belvoc:DirectlyIncreases . }
                  UNION
                  { ?stmt belvoc:hasRelationship belvoc:DirectlyDecreases . }
                }
                {
                  { ?subj a belvoc:ProteinAbundance . }
                  UNION
                  { ?subj a belvoc:ModifiedProteinAbundance . }
                }
                ?subj belvoc:hasConcept ?xName .
                {
                  {
                    ?obj a belvoc:ProteinAbundance .
                    ?obj belvoc:hasConcept ?yName .
                  }
                  UNION
                  {
                    ?obj a belvoc:ModifiedProteinAbundance .
                    ?obj belvoc:hasChild ?proteinY .
                    ?proteinY belvoc:hasConcept ?yName .
                  }
                  UNION
                  {
                    ?obj a belvoc:AbundanceActivity .
                    ?obj belvoc:hasChild ?objChild .
                    ?objChild a belvoc:ProteinAbundance .
                    ?objChild belvoc:hasConcept ?yName .
                  }
                }
                FILTER (?xName != ?yName)
            }
        """
        res_stmts = self.g.query(q_stmts)

        logger.info("Protein -> Protein/Activity statements:")
        logger.info("---------------------------------------")
        for stmt in res_stmts:
            stmt_str = strip_statement(stmt[0])
            logger.info(stmt_str)
            self.degenerate_stmts.append(stmt_str)