MCPcopy Create free account
hub / github.com/MegEngine/MegCC / piecewise_normalize

Function piecewise_normalize

ci/compare_vec_distance.py:52–72  ·  view source on GitHub ↗
(score, left, right, threshold, new_left, new_right,
                        new_threshold)

Source from the content-addressed store, hash-verified

50
51
52def piecewise_normalize(score, left, right, threshold, new_left, new_right,
53 new_threshold):
54 if not (score >= left and score <= right):
55 return new_left
56
57 ret = 0
58 if score < threshold:
59 ret = (score - left) / (threshold - left) * (new_threshold -
60 new_left) + new_left
61 if ret < new_left:
62 ret = new_left
63 if ret >= new_threshold:
64 ret = new_threshold - 1
65 else:
66 ret = (score - threshold) / (right - threshold) * (
67 new_right - new_threshold) + new_threshold
68 if ret <= new_threshold:
69 ret = new_threshold + 1
70 if ret > new_right:
71 ret = new_right
72 return ret
73
74
75def get_spy_similar(v1, v2):

Callers 1

get_spy_similarFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected