diff --git a/dvc/command/metrics.py b/dvc/command/metrics.py index ddc9a2bd52..0f07bffc12 100644 --- a/dvc/command/metrics.py +++ b/dvc/command/metrics.py @@ -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) diff --git a/tests/unit/command/test_metrics.py b/tests/unit/command/test_metrics.py index 7a520dddfc..d254da4e56 100644 --- a/tests/unit/command/test_metrics.py +++ b/tests/unit/command/test_metrics.py @@ -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" + )