mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-26 17:13:17 +00:00
feat: Add digit-based number range generation for chain sum tasks
This commit is contained in:
parent
3d9b48ba31
commit
d46f338160
2 changed files with 43 additions and 2 deletions
|
|
@ -49,3 +49,27 @@ def test_chain_sum_items():
|
|||
# Verify the answer matches the expression
|
||||
answer = eval(expression) # Safe here as we control the expression
|
||||
assert str(answer) == item["answer"]
|
||||
|
||||
|
||||
def test_chain_sum_number_ranges():
|
||||
"""Test that generated numbers respect digit constraints"""
|
||||
config = ChainSumConfig(
|
||||
min_terms=2,
|
||||
max_terms=2, # Fix to 2 terms for easier testing
|
||||
min_digits=3, # Should generate numbers >= 100
|
||||
max_digits=3, # Should generate numbers <= 999
|
||||
size=50,
|
||||
seed=42
|
||||
)
|
||||
dataset = ChainSum(config)
|
||||
|
||||
for i in range(len(dataset)):
|
||||
item = dataset[i]
|
||||
expression = item["metadata"]["expression"]
|
||||
|
||||
# Extract numbers from expression
|
||||
numbers = [int(n) for n in expression.split() if n.isdigit()]
|
||||
|
||||
# Verify each number is in the correct range
|
||||
for num in numbers:
|
||||
assert 100 <= num <= 999, f"Number {num} outside valid range for 3 digits"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue