Python — confused by numpy's piecewise function
问题 I'm trying to implement a piecewise function in Python. Since I'm using quite a few tools from numpy, I simply import everything from it (i.e. from numpy import * ). My piecewise function is defined as LinQuad = piecewise( t, [t < 1, t >= 1], [lambda t : t, lambda t : t**2] ) which results in the error NameError: global name 't' is not defined . I don't understand why I should define t — after all, it is not necessary to define t for a simple lambda function Lin = lambda t : t . In some