Today I Learned
Python Stupid numpy.piecewise
The piecewise()
function in numpy is not very good. Due to the writing of the function, one wouldn’t be surprised to encounter the following error,
in which n
is the length of condition list and n2
is the length of function list.
To avoid it, the input should always be prepared as following