mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-19 12:58:07 +00:00
parent
8ccc4d7b0c
commit
9bb6d028a3
3 changed files with 50 additions and 8 deletions
|
|
@ -2,17 +2,21 @@
|
|||
|
||||
import pytest
|
||||
|
||||
from reasoning_gym.arithmetic.count_bits import CountBitsConfig, CountBitsDataset
|
||||
from reasoning_gym.arithmetic.count_bits import CountBitsConfig, CountBitsCurriculum, CountBitsDataset
|
||||
|
||||
|
||||
def test_count_bits_config_validation():
|
||||
"""Test that invalid configs raise appropriate errors"""
|
||||
with pytest.raises(AssertionError):
|
||||
config = CountBitsConfig(max_n=-1) # Negative not allowed
|
||||
config = CountBitsConfig(min_n=-1) # Negative not allowed
|
||||
config.validate()
|
||||
|
||||
with pytest.raises(AssertionError):
|
||||
config = CountBitsConfig(max_n=0) # Zero not allowed
|
||||
config = CountBitsConfig(min_n=0) # Zero not allowed
|
||||
config.validate()
|
||||
|
||||
with pytest.raises(AssertionError):
|
||||
config = CountBitsConfig(min_n=10, max_n=5) # min_n > max_n
|
||||
config.validate()
|
||||
|
||||
|
||||
|
|
@ -28,7 +32,7 @@ def test_count_bits_dataset_deterministic():
|
|||
|
||||
def test_count_bits_dataset_items():
|
||||
"""Test basic properties of generated items"""
|
||||
config = CountBitsConfig(max_n=10, size=10, seed=42)
|
||||
config = CountBitsConfig(min_n=1, max_n=1_000_000, size=10, seed=42)
|
||||
dataset = CountBitsDataset(config)
|
||||
|
||||
for i in range(len(dataset)):
|
||||
|
|
@ -49,7 +53,7 @@ def test_count_bits_dataset_items():
|
|||
binary = item["metadata"]["binary"]
|
||||
|
||||
# Verify values
|
||||
assert number <= config.max_n
|
||||
assert config.min_n <= number <= config.max_n
|
||||
assert solution >= 0
|
||||
assert set(binary) <= {"0", "1"}
|
||||
|
||||
|
|
@ -81,3 +85,19 @@ def test_count_bits_answer():
|
|||
count += number & 1
|
||||
number >>= 1
|
||||
assert solution == count
|
||||
|
||||
|
||||
def test_count_bits_curriculum():
|
||||
curriculum = CountBitsCurriculum()
|
||||
|
||||
base_value = {"size": 150, "seed": 1}
|
||||
|
||||
base_cfg: CountBitsConfig = curriculum.generate_configuration(base_value)
|
||||
assert base_cfg.seed == 1
|
||||
assert base_cfg.size == 150
|
||||
assert base_cfg.min_n == 1_000 and base_cfg.max_n == 1_000
|
||||
|
||||
# test incrementing attribute levels
|
||||
curriculum.increment_attr_level("n")
|
||||
increased_cfg = curriculum.generate_configuration(base_value)
|
||||
assert increased_cfg.min_n == 1_000 and increased_cfg.max_n == 1_000_000
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue