MCPcopy
hub / github.com/treeverse/dvc / _format_field

Function _format_field

dvc/compare.py:281–295  ·  view source on GitHub ↗
(
    val: Any, precision: Optional[int] = None, round_digits: bool = False
)

Source from the content-addressed store, hash-verified

279
280
281def _format_field(
282 val: Any, precision: Optional[int] = None, round_digits: bool = False
283) -> str:
284 def _format(_val):
285 if isinstance(_val, float) and precision:
286 if round_digits:
287 return round(_val, precision)
288 return _normalize_float(_val, precision)
289 if isinstance(_val, abc.Mapping):
290 return {k: _format(v) for k, v in _val.items()}
291 if isinstance(_val, list):
292 return [_format(x) for x in _val]
293 return _val
294
295 return str(_format(val))
296
297
298def diff_table(

Callers 3

_d_cellsFunction · 0.90
diff_tableFunction · 0.85
metrics_tableFunction · 0.85

Calls 1

_formatFunction · 0.85

Tested by

no test coverage detected