Attempting to run this code in Python3 Jupyter notebook :
t = namedtuple('a', 'b')
a = [1,0,1]
b = [1,1,1]
Out, In = np.asanyarray(a), np.asanyarray(b)
t(Out.shape[0], *In.shape)
returns error :
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-151-7955ff03a60d> in <module>()
3 b = [1,1,1]
4 Out, In = np.asanyarray(a), np.asanyarray(b)
----> 5 t(Out.shape[0], *In.shape)
TypeError: __new__() takes 2 positional arguments but 3 were given
Is possible to create namedtuple with two arguments ?
Update :
Why does this not cause similar issue :
t = namedtuple('ps', 'Out In S')
a = np.asanyarray([[1]])
b = np.asanyarray([[1]])
d = t(a.shape[0], *b.shape)
d
computes :
ps(Out=1, In=1, S=1)
Update 2 :
Think i understand now namedtuple('ps', 'Out In S')
translates to namedtuple('name_of_tuple', 'tuple_values_seperated_by_spaces')