mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-23 16:55:05 +00:00
formatting, cleanup
This commit is contained in:
parent
b767e58e48
commit
3dc80be7d2
12 changed files with 189 additions and 376 deletions
|
|
@ -1,50 +1,44 @@
|
|||
import pytest
|
||||
|
||||
from .simple_equations import simple_equations_dataset
|
||||
|
||||
|
||||
def test_simple_equations_generation():
|
||||
dataset = simple_equations_dataset(seed=42, size=10)
|
||||
|
||||
|
||||
for item in dataset:
|
||||
# Check required keys exist
|
||||
assert "question" in item
|
||||
assert "answer" in item
|
||||
assert "metadata" in item
|
||||
|
||||
|
||||
# Validate answer is a string of digits
|
||||
assert item["answer"].isdigit()
|
||||
|
||||
|
||||
# Validate equation format
|
||||
equation = item["metadata"]["equation"]
|
||||
variable = item["metadata"]["variable"]
|
||||
assert "=" in equation
|
||||
assert variable in equation
|
||||
|
||||
|
||||
# Validate question format
|
||||
question = item["question"]
|
||||
assert variable in question
|
||||
assert equation in question
|
||||
assert any(
|
||||
prompt in question
|
||||
for prompt in [
|
||||
"Find the value of",
|
||||
"Solve for",
|
||||
"Determine the value of"
|
||||
]
|
||||
)
|
||||
assert any(prompt in question for prompt in ["Find the value of", "Solve for", "Determine the value of"])
|
||||
|
||||
|
||||
def test_simple_equations_config():
|
||||
# Test invalid config raises assertion
|
||||
with pytest.raises(AssertionError):
|
||||
dataset = simple_equations_dataset(min_terms=0)
|
||||
|
||||
|
||||
with pytest.raises(AssertionError):
|
||||
dataset = simple_equations_dataset(max_terms=1, min_terms=2)
|
||||
|
||||
|
||||
with pytest.raises(AssertionError):
|
||||
dataset = simple_equations_dataset(min_value=0)
|
||||
|
||||
|
||||
with pytest.raises(AssertionError):
|
||||
dataset = simple_equations_dataset(operators=())
|
||||
|
||||
|
|
@ -52,7 +46,7 @@ def test_simple_equations_config():
|
|||
def test_deterministic_generation():
|
||||
dataset1 = simple_equations_dataset(seed=42, size=5)
|
||||
dataset2 = simple_equations_dataset(seed=42, size=5)
|
||||
|
||||
|
||||
for i in range(5):
|
||||
assert dataset1[i]["question"] == dataset2[i]["question"]
|
||||
assert dataset1[i]["answer"] == dataset2[i]["answer"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue