MCPcopy Create free account
hub / github.com/Alpha-VLLM/LLaMA2-Accessory / delete_extra_zero

Function delete_extra_zero

accessory/eval_mm/utils/math_utils.py:115–128  ·  view source on GitHub ↗

删除小数点后多余的0

(n)

Source from the content-addressed store, hash-verified

113
114
115def delete_extra_zero(n):
116 '''删除小数点后多余的0'''
117 try:
118 n=float(n)
119 except:
120 print("None {}".format(n))
121 return n
122 if isinstance(n, int):
123 return str(n)
124 if isinstance(n, float):
125 n = str(n).rstrip('0') # 删除小数点后多余的0
126 n = int(n.rstrip('.')) if n.endswith('.') else float(n) # 只剩小数点直接转int,否则转回float
127 n=str(n)
128 return n
129
130
131def _fix_fracs(string):

Callers 1

answer_cleanFunction · 0.85

Calls 1

printFunction · 0.85

Tested by

no test coverage detected