metrics: diff: fix float precision formatting (#3609)

Texttable will try to detect the column type automatically, which
results in a low precision of the float that it is showing. We need to
disable that auto-formatting and just use `str(val)` instead.
This commit is contained in:
Ruslan Kuprieiev
2020-04-07 19:42:25 +03:00
committed by GitHub
parent f325921315
commit 26980ae45b
2 changed files with 12 additions and 0 deletions
+3
View File
@@ -121,6 +121,9 @@ def _show_diff(diff):
table = Texttable()
# disable automatic formatting
table.set_cols_dtype(["t", "t", "t", "t"])
# remove borders to make it easier for users to copy stuff
table.set_chars(("", "", "", ""))
table.set_deco(0)
+9
View File
@@ -119,3 +119,12 @@ def test_metrics_show(dvc, mocker):
all_branches=True,
all_commits=True,
)
def test_metrics_diff_prec():
assert _show_diff(
{"other.json": {"a.b": {"old": 0.0042, "new": 0.0043, "diff": 0.0001}}}
) == (
" Path Metric Value Change\n"
"other.json a.b 0.0043 0.0001"
)