Update comprehensive-arithmetic-problems-carries.py
Browse files
comprehensive-arithmetic-problems-carries.py
CHANGED
@@ -190,27 +190,32 @@ class ArithmeticProblemsDataset(GeneratorBasedBuilder):
|
|
190 |
raise ValueError(f"Invalid operator: {operator}")
|
191 |
|
192 |
is_float1, is_float2 = operation_type
|
193 |
-
|
194 |
-
|
195 |
-
max_val=max_value,
|
196 |
-
is_float=is_float1,
|
197 |
-
max_rounding_precision=max_rounding_precision,
|
198 |
-
)
|
199 |
-
if with_carry:
|
200 |
-
# for testing addition
|
201 |
-
operand2 = self._generate_number(
|
202 |
-
min_val=min_value,
|
203 |
-
max_val=max_value - operand1 - 1,
|
204 |
-
is_float=is_float2,
|
205 |
-
max_rounding_precision=max_rounding_precision,
|
206 |
-
)
|
207 |
-
else:
|
208 |
-
operand2 = self._generate_number(
|
209 |
min_val=min_value,
|
210 |
max_val=max_value,
|
211 |
-
is_float=
|
212 |
max_rounding_precision=max_rounding_precision,
|
213 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
|
215 |
if operator == Operator.SUBTRACT:
|
216 |
result = operand1 - operand2
|
|
|
190 |
raise ValueError(f"Invalid operator: {operator}")
|
191 |
|
192 |
is_float1, is_float2 = operation_type
|
193 |
+
while True:
|
194 |
+
operand1 = self._generate_number(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
min_val=min_value,
|
196 |
max_val=max_value,
|
197 |
+
is_float=is_float1,
|
198 |
max_rounding_precision=max_rounding_precision,
|
199 |
)
|
200 |
+
if with_carry:
|
201 |
+
try:
|
202 |
+
# for testing addition
|
203 |
+
operand2 = self._generate_number(
|
204 |
+
min_val=min_value,
|
205 |
+
max_val=max_value - operand1 - 1,
|
206 |
+
is_float=is_float2,
|
207 |
+
max_rounding_precision=max_rounding_precision,
|
208 |
+
)
|
209 |
+
except Exception:
|
210 |
+
continue
|
211 |
+
else:
|
212 |
+
operand2 = self._generate_number(
|
213 |
+
min_val=min_value,
|
214 |
+
max_val=max_value,
|
215 |
+
is_float=is_float2,
|
216 |
+
max_rounding_precision=max_rounding_precision,
|
217 |
+
)
|
218 |
+
break
|
219 |
|
220 |
if operator == Operator.SUBTRACT:
|
221 |
result = operand1 - operand2
|