Beispiel #1
0
 def test_pack_args(self, parameter_type, args, kwargs,
                    expected_value_string):
     self.assertEqual(
         str(
             function_utils.pack_args(parameter_type, args, kwargs,
                                      NoopIngestContextForTest())),
         expected_value_string)
Beispiel #2
0
 def __call__(self, *args, **kwargs):
   if not isinstance(self._comp.type_signature,
                     computation_types.FunctionType):
     raise SyntaxError(
         'Function-like invocation is only supported for values of '
         'functional types, but the value being invoked is of type '
         '{} that does not support invocation.'.format(
             str(self._comp.type_signature)))
   if args or kwargs:
     args = [to_value(x, None, self._context_stack) for x in args]
     kwargs = {
         k: to_value(v, None, self._context_stack)
         for k, v in six.iteritems(kwargs)
     }
     arg = function_utils.pack_args(self._comp.type_signature.parameter, args,
                                    kwargs, self._context_stack.current)
     arg = ValueImpl.get_comp(to_value(arg, None, self._context_stack))
   else:
     arg = None
   return ValueImpl(
       computation_building_blocks.Call(self._comp, arg), self._context_stack)