[fix #484] resolve basic_arithmetic fails when size is large (#485)

* [fix] resolve basic_arithmetic fails when size is large by replacing zero divisor with 1
This commit is contained in:
theblackcat102 2025-07-07 16:46:23 +08:00 committed by GitHub
parent bf451d5197
commit 2d19f13e0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View file

@ -191,6 +191,9 @@ class BasicArithmeticDataset(ProceduralDataset):
space_parts.append(" ")
space_parts.append(p)
expression = "".join(space_parts).strip()
# Avoid division-by-zero in final evaluation by converting '/0' patterns to '/1'
if "/ 0" in expression:
expression = expression.replace("/ 0", "/ 1")
result = eval_floordiv(expression) # Note: eval is safe here as we control the input
return expression, result