INNER CODE UNIT · Python
_find_nearest
aeturrell/skimpy · src/skimpy/__init__.py:303
def _find_nearest(array: np.ndarray, value: float) -> float:
"""Find the nearest numerical match to value in an array.
Args:
array (np.ndarray): An array of numbers to match with.
value (float): Single value to find an entry in array that is close.
Returns:
float: The entry in array that is closest to value.
"""
array = np.asarray(array)
idx = (np.abs(array - value)).argmin()
return array[idx]
@typing.no_type_check
def _create_unicode_hist(series: pd.Series) -> pd.Series:
"""Return a histogram rendered in block unicode.