Fix: overlap cannot be properly applied (#12828)

### What problem does this PR solve?

Overlap cannot be properly applied.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Yongteng Lei
2026-01-27 12:43:01 +08:00
committed by GitHub
parent 413956e9dd
commit f096917eeb
3 changed files with 22 additions and 8 deletions

View File

@ -14,6 +14,7 @@
# limitations under the License.
#
def get_float(v):
"""
Convert a value to float, handling None and exceptions gracefully.
@ -39,8 +40,19 @@ def get_float(v):
42.0
"""
if v is None:
return float('-inf')
return float("-inf")
try:
return float(v)
except Exception:
return float('-inf')
return float("-inf")
def normalize_overlapped_percent(overlapped_percent):
try:
value = float(overlapped_percent)
except (TypeError, ValueError):
return 0
if 0 < value < 1:
value *= 100
value = int(value)
return max(0, min(value, 90))