MCPcopy Create free account
hub / github.com/InternRobotics/G2VLM / format_matrix_str

Function format_matrix_str

eval_code/recons/utils/messages.py:63–82  ·  view source on GitHub ↗
(matrix)

Source from the content-addressed store, hash-verified

61 updated_data.to_csv(file_path, index=False)
62
63def format_matrix_str(matrix):
64 def format_float(num, total_width=20, decimal_places=12):
65 # strip all right 0s, then strip '.'
66 s = f"{num:{total_width}.{decimal_places}f}".rstrip("0").rstrip(".")
67 # add space to the left
68 return f"{s:>{total_width}}"
69 formatted = [
70 [
71 # f"{num:20.12f}".rstrip("0").rstrip(".") if "." in f"{num}" else f"{num:20}"
72 # f"{num:20.12f}" if "." in f"{num}" else f"{num:20}"
73 format_float(num, total_width=15, decimal_places=8)
74 for num in row
75 ]
76 for row in matrix
77 ]
78 rows = [
79 f" [{', '.join(num for num in row)}]"
80 for row in formatted
81 ]
82 return " [\n" + ",\n".join(rows) + "\n ]"
83
84def save_list_of_matrices(matrices_tosave: List[List[List[float]]], save_path: str) -> None:
85 json_str = "[\n" + ",\n".join(format_matrix_str(mat) for mat in matrices_tosave) + "\n]"

Callers 1

save_list_of_matricesFunction · 0.85

Calls 2

format_floatFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected