MCPcopy
hub / github.com/EleutherAI/lm-evaluation-harness / fix_a_slash_b

Function fix_a_slash_b

lm_eval/tasks/hendrycks_math/utils.py:129–141  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

127
128
129def fix_a_slash_b(string):
130 if len(string.split("/")) != 2:
131 return string
132 a = string.split("/")[0]
133 b = string.split("/")[1]
134 try:
135 a = int(a)
136 b = int(b)
137 assert string == "{}/{}".format(a, b)
138 new_string = "\\frac{" + str(a) + "}{" + str(b) + "}"
139 return new_string
140 except AssertionError:
141 return string
142
143
144def remove_right_units(string):

Callers 1

strip_stringFunction · 0.70

Calls 1

formatMethod · 0.80

Tested by

no test coverage detected