fix: Remove operators configuration from simple equations dataset

This commit is contained in:
Andreas Koepf (aider) 2025-01-24 19:15:28 +01:00
parent 940b810a43
commit cf2434b3aa
2 changed files with 3 additions and 35 deletions

View file

@ -17,7 +17,6 @@ class SimpleEquationsConfig:
max_terms: int = 4 # Maximum number of terms
min_value: int = 1 # Minimum value for constants
max_value: int = 100 # Maximum value for constants
operators: tuple = ("+", "-", "*") # Allowed operators
seed: Optional[int] = None
size: int = 500
@ -27,7 +26,6 @@ class SimpleEquationsConfig:
assert self.max_terms >= self.min_terms, "max_terms must be >= min_terms"
assert self.min_value > 0, "min_value must be positive"
assert self.max_value >= self.min_value, "max_value must be >= min_value"
assert len(self.operators) > 0, "must specify at least one operator"
class SimpleEquationsDataset(ProceduralDataset):
@ -97,16 +95,13 @@ class SimpleEquationsDataset(ProceduralDataset):
# Replace one random term with the variable term
var_pos = rng.randint(0, num_terms - 1)
if "*" in self.config.operators:
coef = rng.randint(self.config.min_value, self.config.max_value)
terms[var_pos] = coef * x
else:
terms[var_pos] = x
coef = rng.randint(self.config.min_value, self.config.max_value)
terms[var_pos] = coef * x
# Apply operators between terms
expr = terms[0]
for i in range(1, num_terms):
op = rng.choice(self.config.operators)
op = rng.choice(("+", "-", "*"))
if op == "+":
expr = expr + terms[i]
elif op == "-":
@ -135,7 +130,6 @@ def simple_equations_dataset(
max_terms: int = 5,
min_value: int = 1,
max_value: int = 100,
operators: tuple = ("+", "-", "*"),
seed: Optional[int] = None,
size: int = 500,
) -> SimpleEquationsDataset:
@ -145,7 +139,6 @@ def simple_equations_dataset(
max_terms=max_terms,
min_value=min_value,
max_value=max_value,
operators=operators,
seed=seed,
size=size,
)