For our reference: numpy's piecewise implementation https://github.com/numpy/numpy/blob/v1.20.0/numpy/lib/function_base.py#L500-L618