MCPcopy Create free account
hub / github.com/PRIME-RL/PRIME / split_tuple

Function split_tuple

data_preprocessing/math_util/__init__.py:221–237  ·  view source on GitHub ↗

Split the elements in a tuple/interval, while handling well-formatted commas in large numbers

(expr: str)

Source from the content-addressed store, hash-verified

219
220
221def split_tuple(expr: str):
222 """
223 Split the elements in a tuple/interval, while handling well-formatted commas in large numbers
224 """
225 expr = _strip_properly_formatted_commas(expr)
226 if len(expr) == 0:
227 return []
228 if (
229 len(expr) > 2
230 and expr[0] in TUPLE_CHARS
231 and expr[-1] in TUPLE_CHARS
232 and all([ch not in expr[1:-1] for ch in TUPLE_CHARS])
233 ):
234 elems = [elem.strip() for elem in expr[1:-1].split(",")]
235 else:
236 elems = [expr]
237 return elems
238
239
240def grade_answer(given_answer: str, ground_truth: str) -> bool:

Callers 1

grade_answerFunction · 0.70

Calls 1

Tested by

no test coverage detected