d7d7c84f7750b95fad039bd8dcd14c26b0a115e6,dev/ideas/devices/cpp_standalone.py,,freeze,#Any#Any#,73

Before Change


def freeze(code, ns):
    // this is a bit of a hack, it should be passed to the template somehow
    for k, v in ns.items():
        if isinstance(v, float):
            code = ("const double %s = %s;\n" % (k, repr(v)))+code
        elif isinstance(v, int):
            code = ("const int %s = %s;\n" % (k, repr(v)))+code
    return code

if not os.path.exists("output"):
    os.mkdir("output")

After Change


    // this is a bit of a hack, it should be passed to the template somehow
    for k, v in ns.items():
        if isinstance(v, (int, float)):
            code = word_substitute(code, {k: repr(v)})
    return code

if not os.path.exists("output"):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: brian-team/brian2
Commit Name: d7d7c84f7750b95fad039bd8dcd14c26b0a115e6
Time: 2013-08-30
Author: o9UaUryywz
File Name: dev/ideas/devices/cpp_standalone.py
Class Name:
Method Name: freeze


Project Name: brian-team/brian2
Commit Name: 1e3b72a859d6943d8135e722bfc9f069932d672a
Time: 2015-11-27
Author: marcel.stimberg@inserm.fr
File Name: brian2/codegen/generators/cpp_generator.py
Class Name: CPPCodeGenerator
Method Name: translate_expression


Project Name: brian-team/brian2
Commit Name: 1e3b72a859d6943d8135e722bfc9f069932d672a
Time: 2015-11-27
Author: marcel.stimberg@inserm.fr
File Name: brian2/codegen/generators/numpy_generator.py
Class Name: NumpyCodeGenerator
Method Name: translate_expression