piecewise numpy function with integer arguments
问题 I define the piecewise function def Li(x): return piecewise(x, [x < 0, x >= 0], [lambda t: sin(t), lambda t: cos(t)]) And when I evaluate Li(1.0) The answer is correct Li(1.0)=array(0.5403023058681398) , But if I write Li(1) the answer is array(0) . I don't understand this behaviour. 回答1: It seems that piecewise() converts the return values to the same type as the input so, when an integer is input an integer conversion is performed on the result, which is then returned. Because sine and