1 | initial version |
Your function fuser
changes values of its arguments, and in inconsistent manner - eg., second argument w
comes as a list of lists but after modifications done by fuser
some elements of w
may change type from list to integer.
The argument change is further propagated to function final(w)
which also changes the value of w
and in inconsistent manner. As a quick fix one may change the call final(u)
into final(u.copy())
to protect the value of u
from modification which then results in the eror, although I'm not sure if this is consistent with the purpose of the function. On general scale it's better to change the design of functions so that modifications of arguments are either avoided (via use of new variables), or done in consistent manner.
2 | No.2 Revision |
Your function fuser
changes values of its arguments, and in inconsistent manner - eg., second argument w
comes as a list of lists but after modifications done by fuser
some elements of w
may change type from list to integer.
integer.
The argument change is further propagated to function final(w)
which also changes the value of w
and in inconsistent manner. As I do not know if the argument change is intended, but if so it's done wrong.
If it's not intended, then a quick fix one may change would changing the call final(u)
into final(u.copy())
to protect the value of u
from modification which then results in the eror, although I'm not sure if this is consistent with the purpose of the function. eror.
On general scale it's better to change the design of functions so that modifications of arguments are either avoided (via use of new variables), or done in consistent manner. manner.