mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-19 12:58:07 +00:00
refactor: Replace Random import with random module and update type hints
This commit is contained in:
parent
654bed3146
commit
358829cc60
1 changed files with 5 additions and 5 deletions
|
|
@ -1,5 +1,5 @@
|
|||
from dataclasses import dataclass
|
||||
from random import Random
|
||||
import random
|
||||
from typing import Optional
|
||||
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ class ChainSum:
|
|||
self.config = config
|
||||
self.config.validate()
|
||||
# Generate base seed if none provided
|
||||
self.seed = config.seed if config.seed is not None else Random().randint(0, 2**32)
|
||||
self.seed = config.seed if config.seed is not None else random.randint(0, 2**32)
|
||||
|
||||
def __len__(self) -> int:
|
||||
return self.config.size
|
||||
|
|
@ -50,8 +50,8 @@ class ChainSum:
|
|||
- answer: str, the ground truth result
|
||||
- metadata: dict with generation parameters
|
||||
"""
|
||||
# Create deterministic RNG directly from base seed and idx
|
||||
item_rng = Random(self.seed + idx)
|
||||
# Create deterministic RNG from base seed and idx
|
||||
item_rng = random.Random(self.seed + idx)
|
||||
|
||||
num_terms = item_rng.randint(self.config.min_terms, self.config.max_terms)
|
||||
num_digits = item_rng.randint(self.config.min_digits, self.config.max_digits)
|
||||
|
|
@ -68,7 +68,7 @@ class ChainSum:
|
|||
}
|
||||
}
|
||||
|
||||
def _generate_task(self, rng: Random, num_terms: int, num_digits: int) -> tuple[str, int]:
|
||||
def _generate_task(self, rng: random.Random, num_terms: int, num_digits: int) -> tuple[str, int]:
|
||||
"""Generate a chain sum task
|
||||
|
||||
Args:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue