MCPcopy Create free account
hub / github.com/agentscope-ai/Trinity-RFT / format_data_str

Method format_data_str

trinity/utils/monitor.py:77–97  ·  view source on GitHub ↗
(self, data: dict, step: int)

Source from the content-addressed store, hash-verified

75 return {}
76
77 def format_data_str(self, data: dict, step: int) -> str:
78 cleaned_data = {
79 k: (
80 v.item()
81 if hasattr(v, "item")
82 else float(v) # tensor or numpy scalar
83 if isinstance(v, (np.integer, np.floating))
84 else v # numpy types
85 )
86 for k, v in data.items()
87 }
88 # Format floats to reasonable precision using default str (avoids scientific notation and long decimals)
89 formatted_data = (
90 "{"
91 + ", ".join(
92 repr(k) + ": " + (f"{v:.6g}" if isinstance(v, float) else repr(v))
93 for k, v in cleaned_data.items()
94 )
95 + "}"
96 )
97 return f"Step {step}: {formatted_data}"
98
99
100class TensorboardMonitor(Monitor):

Callers 4

logMethod · 0.80
logMethod · 0.80
logMethod · 0.80
logMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected