mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-23 16:55:05 +00:00
feat: Add rule composition support to PatternRule
This commit is contained in:
parent
3381669f98
commit
a2686341a3
2 changed files with 20 additions and 2 deletions
|
|
@ -23,11 +23,17 @@ def test_pattern_rule():
|
|||
# Test simple addition
|
||||
rule = PatternRule([Operation.ADD], [2])
|
||||
assert rule.apply([1, 3], 1) == 5
|
||||
|
||||
|
||||
# Test composition
|
||||
rule = PatternRule([Operation.DOUBLE, Operation.ADD], [0, 3])
|
||||
assert rule.apply([1, 4], 1) == 11 # (4 * 2) + 3
|
||||
|
||||
# Test rule composition
|
||||
rule1 = PatternRule([Operation.DOUBLE], [0]) # Double the number
|
||||
rule2 = PatternRule([Operation.ADD], [3]) # Add 3
|
||||
composed = PatternRule.compose([rule1, rule2])
|
||||
assert composed.apply([1, 4], 1) == 11 # (4 * 2) + 3
|
||||
|
||||
|
||||
def test_sequence_dataset_deterministic():
|
||||
"""Test that dataset generates same items with same seed"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue