Issue
I a function described as follows (very simplified version):
def my_func(*args):
c = other_func(args)
return c
And other_func is defined as:
def other_func(a, b):
c = a + b
return c
I have also two numpy arrays:
a = [[1.] [2.]]
b = [[2.] [5.]]
I want to pass a and b to my_func and retrieve them exactly as I passed them: The result I want is :
c = my_func(a, b)
With :
c = [[3.] [7.]]
But when I call my_func like above, I get this error:
TypeError: other_func missing 1 required positional argument: 'b'
I think the problem is that my_func is not able to unpack the data. I looked at an almost similar topic (link below) but It doesn't help me enough to fix my problem. Also, I don't want to use a Loop, it will not be practical for my work.
Link : How to split list and pass them as separate parameter?
Can anyone help me solve this?
Thank you in advance.
Solution
Change the line
c = other_func(args)
to
c = other_func(*args)
Answered By - NGilbert
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.