Source code for rpylib.numerical.tools
"""Generic helper functions"""
from functools import singledispatch
import numpy as np
@sign.register
def _(x: float):
if x < 0:
return -1.0
return 1.0
[docs]def interval_I(x: float) -> tuple[float, float]:
"""
:return: left or right interval depending on the sign of x
"""
return (-np.inf, x) if x < 0 else (x, np.inf)