Exemple #1
0
 def wrapper(*args, **kwargs):
     spec = inspect.getargspec(f)
     received_arg_count = len(args)
     received_kwargs = kwargs.copy()
     defs = list(spec.defaults)
     for arg in spec.args:
         if received_arg_count:
             received_arg_count -= 1
         elif arg not in received_kwargs:
             kwargs[arg] = defs.pop(0)
         else:
             raise Exception("Value not provided for argument " + arg + ".")
     args = list(args)
     for i, arg in enumerate(args):
         if _is_jumpy(arg):
             args[i] = arg.array
     for k in kwargs:
         v = kwargs[k]
         if _is_jumpy(v):
             kwargs[k] = v.array
     out = f(*args, **kwargs)
     if _is_nd4j(out):
         return array(out)
     elif type(out) is list:
         for i, v in enumerate(out):
             if _is_nd4j(v):
                 out[i] = array(v)
         return out
     elif type(out) is tuple:
         out = list(out)
         for i, v in enumerate(out):
             if _is_nd4j(v):
                 out[i] = array(v)
         return tuple(out)
Exemple #2
0
 def wrapper(*args, **kwargs):
     args = list(args)
     for i, arg in enumerate(args):
         if _is_jumpy(arg):
             args[i] = arg.array
         elif type(arg) is list:
             for j, a in enumerate(arg):
                 if _is_jumpy(a):
                     arg[j] = a.array
         elif type(arg) is tuple:
             arg = list(arg)
             for j, a in enumerate(arg):
                 if _is_jumpy(a):
                     arg[j] = a.array
             args[i] = tuple(arg)
     for k in kwargs:
         v = kwargs[k]
         if _is_jumpy(v):
             kwargs[k] = v.array
     out = f(*args, **kwargs)
     if _is_nd4j(out):
         return array(out)
     elif type(out) is list:
         for i, v in enumerate(out):
             if _is_nd4j(v):
                 out[i] = array(v)
         return out
     elif type(out) is tuple:
         out = list(out)
         for i, v in enumerate(out):
             if _is_nd4j(v):
                 out[i] = array(v)
         return tuple(out)
Exemple #3
0
 def wrapper(*args, **kwargs):
     args = list(args)
     for i, arg in enumerate(args):
         if _is_jumpy(arg):
             args[i] = arg.array
         elif type(arg) is list:
             for j, a in enumerate(arg):
                 if _is_jumpy(a):
                     arg[j] = a.array
         elif type(arg) is tuple:
             arg = list(arg)
             for j, a in enumerate(arg):
                 if _is_jumpy(a):
                     arg[j] = a.array
             args[i] = tuple(arg)
     for k in kwargs:
         v = kwargs[k]
         if _is_jumpy(v):
             kwargs[k] = v.array
     out = f(*args, **kwargs)
     if _is_nd4j(out):
         return array(out)
     elif type(out) is list:
         for i, v in enumerate(out):
             if _is_nd4j(v):
                 out[i] = array(v)
         return out
     elif type(out) is tuple:
         out = list(out)
         for i, v in enumerate(out):
             if _is_nd4j(v):
                 out[i] = array(v)
         return tuple(out)