def capInf(x, copy=False):
x = np.array(x, copy=copy)
mn = np.finfo(x.dtype).min
mx = np.finfo(x.dtype).max
if x.ndim == 0:
if x < mn:
x[...] = mn
if x > mx:
x[...] = mx
else:
x[x < mn] = mn
x[x > mx] = mx
return x