Function
piecewise_normalize
(score, left, right, threshold, new_left, new_right,
new_threshold)
Source from the content-addressed store, hash-verified
| 50 | |
| 51 | |
| 52 | def 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 | |
| 75 | def get_spy_similar(v1, v2): |
Tested by
no test coverage detected