MCPcopy Create free account
hub / github.com/MotrixLab/ViMoGen / find_nearest_value

Function find_nearest_value

datasets/bucket_config.py:7–11  ·  view source on GitHub ↗
(value, arr: np.ndarray, return_idx: bool = True)

Source from the content-addressed store, hash-verified

5
6
7def find_nearest_value(value, arr: np.ndarray, return_idx: bool = True):
8 idx = np.argmin(np.abs(arr - value))
9 if return_idx:
10 return idx
11 return arr[idx]
12
13
14def find_nearest_equal_or_smaller_value(value,

Callers 2

preprocessMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected