c84200e9bb97b39a73778e5b32df3b85cb2614c9,brian2/tests/test_syntax_translation.py,,parse_expressions,#Any#Any#Any#,35

Before Change


        n = 0
        for _ in xrange(numvalues):
            // assign some random values
            ns = dict((v, rand()) for v in varids)
            try:
                r1 = eval(expr, ns)
            except (ZeroDivisionError, ValueError, OverflowError):
                continue
            n += 1

After Change



def parse_expressions(renderer, evaluator, numvalues=10):
    // TODO: add some tests with e.g. 1.0%2.0 etc. once this is implemented in C++
    exprs = """
    a+b+c*d+e-f+g-(b+d)-(a-c)
    a**b**2
    a**(b**2)
    (a**b)**2
    a*(b+c*(a+b)*(a-(c*d)))
    a/b/c-a/(b/c)
    a<b
    a<=b
    a>b
    a>=b
    a==b
    a!=b
    a+1
    1+a
    1+3
    a>0.5 and b>0.5
    a>0.5&b>0.5&c>0.5
    (a>0.5) & (b>0.5) & (c>0.5)
    a>0.5 and b>0.5 or c>0.5
    a>0.5 and b>0.5 or not c>0.5
    2%4
    """
    exprs = [([m for m in get_identifiers(l) if len(m)==1], [], l.strip()) for l in exprs.split("\n") if l.strip()]
    i, imod = 1, 33
    for varids, funcids, expr in exprs:
        pexpr = renderer.render_expr(expr)
        n = 0
        for _ in xrange(numvalues):
            // assign some random values
            ns = {}
            for v in varids:
                ns[v] = float(i)/imod
                i = i%imod+1
            r1 = eval(expr.replace("&", " and ").replace("|", " or "), ns)
            n += 1
            r2 = evaluator(pexpr, ns)
            try:
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: brian-team/brian2
Commit Name: c84200e9bb97b39a73778e5b32df3b85cb2614c9
Time: 2013-06-25
Author: dan.goodman@ens.fr
File Name: brian2/tests/test_syntax_translation.py
Class Name:
Method Name: parse_expressions


Project Name: pantsbuild/pants
Commit Name: 39a57d699153b9fea87d7922c999a1c07c3f5173
Time: 2014-02-21
Author: jsirois@twitter.com
File Name: src/python/twitter/pants/tasks/builddictionary.py
Class Name: BuildBuildDictionary
Method Name: _gen_goals_reference


Project Name: pantsbuild/pants
Commit Name: e231c3060cc377553c5668aadd873c3a5fd6fa6c
Time: 2014-02-20
Author: lhosken@twitter.com
File Name: src/python/twitter/pants/tasks/builddictionary.py
Class Name: BuildBuildDictionary
Method Name: _gen_goals_reference