31269a5197170026985db35c4703cc6e9c805ebf,tangent/reverse_ad.py,ReverseAD,visit_Call,#ReverseAD#Any#,659

Before Change



    // If any keyword arguments weren"t passed, we fill them using the
    // defaults of the original function
    if grads.DEFAULT in bound_args.arguments.values():
      // Build a mapping from names to defaults
      args = quoting.parse_function(func).body[0].args
      defaults = {}
      for arg, default in zip(*map(reversed, [args.args,
                                              args.defaults])):
        defaults[arg.id] = default
      for arg, default in zip(args.kwonlyargs, args.kw_defaults):
        if default is not None:
          defaults[arg.id] = default
      for name, value in bound_args.arguments.items():
        if value is grads.DEFAULT:
          bound_args.arguments[name] = defaults[name]

    // Let"s fill in the template. The first argument is the output, which
    // was stored in a temporary variable
    output_name = six.get_function_code(template_).co_varnames[0]
    arg_replacements = {output_name: ast_.copy_node(self.target)}
    arg_replacements.update(bound_args.arguments)

After Change



    // Fill in any missing kwargs with the defaults from the template
    args = quoting.parse_function(template_).body[0].args
    kwargs = dict(zip(*map(reversed, [args.args, args.defaults])))
    kwargs.update(dict(zip(args.kwonlyargs, args.kw_defaults)))
    for arg, val in kwargs.items():
      if arg.id not in bound_args.arguments:
        bound_args.arguments[arg.id] = val
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 11

Instances


Project Name: google/tangent
Commit Name: 31269a5197170026985db35c4703cc6e9c805ebf
Time: 2017-11-10
Author: bart.vanmerrienboer@gmail.com
File Name: tangent/reverse_ad.py
Class Name: ReverseAD
Method Name: visit_Call


Project Name: lingpy/lingpy
Commit Name: 910f6efdd27d489b759a44ccdbb4f5922bcf1b78
Time: 2013-07-20
Author: mattis.list@posteo.de
File Name: lingpy/align/multiple.py
Class Name: Multiple
Method Name: lib_align


Project Name: lingpy/lingpy
Commit Name: 910f6efdd27d489b759a44ccdbb4f5922bcf1b78
Time: 2013-07-20
Author: mattis.list@posteo.de
File Name: lingpy/align/multiple.py
Class Name: Multiple
Method Name: prog_align


Project Name: google/tangent
Commit Name: 31269a5197170026985db35c4703cc6e9c805ebf
Time: 2017-11-10
Author: bart.vanmerrienboer@gmail.com
File Name: tangent/forward_ad.py
Class Name: ForwardAD
Method Name: visit_Call