mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-26 17:13:17 +00:00
fix unit tests, lower python dependency to 3.9
This commit is contained in:
parent
ee67374aae
commit
ad9f0d265c
11 changed files with 66 additions and 56 deletions
|
|
@ -1,17 +1,18 @@
|
|||
import pytest
|
||||
from reasoning_gym.algorithmic.sentence_reordering import (
|
||||
SentenceReorderingConfig,
|
||||
SentenceReorderingDataset,
|
||||
)
|
||||
|
||||
from reasoning_gym.algorithmic.sentence_reordering import SentenceReorderingConfig, SentenceReorderingDataset
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def config():
|
||||
return SentenceReorderingConfig(min_words_in_sentence=5, max_words_in_sentence=5, seed=42, size=10)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def dataset(config):
|
||||
return SentenceReorderingDataset(config=config)
|
||||
|
||||
|
||||
def test_config_validation(config):
|
||||
# Test that the config validation does not raise any exceptions
|
||||
try:
|
||||
|
|
@ -19,6 +20,7 @@ def test_config_validation(config):
|
|||
except Exception as e:
|
||||
pytest.fail(f"Config validation raised an exception: {e}")
|
||||
|
||||
|
||||
def test_generate_sentence_dataset(dataset):
|
||||
sentence = "This is a test sentence for reordering"
|
||||
result = dataset._generate_sentence_dataset(sentence, seed=42, idx=0, shuffle=True)
|
||||
|
|
@ -27,12 +29,15 @@ def test_generate_sentence_dataset(dataset):
|
|||
assert result["input"] != result["goal"]
|
||||
assert sorted(result["input"].split()) == sorted(result["goal"].split())
|
||||
|
||||
|
||||
def test_getitem(dataset, config):
|
||||
item = dataset[0]
|
||||
assert "question" in item
|
||||
assert "answer" in item
|
||||
assert "metadata" in item
|
||||
assert item["metadata"]["word_count"] >= config.min_words_in_sentence
|
||||
assert item["metadata"]["word_count"] <= config.max_words_in_sentence
|
||||
|
||||
|
||||
def test_key_error_in_getitem(dataset):
|
||||
# Modify the dataset to include an incorrect key
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue