diff --git a/dvc/api/experiments.py b/dvc/api/experiments.py index 58861c3aef..4a1ead96e8 100644 --- a/dvc/api/experiments.py +++ b/dvc/api/experiments.py @@ -53,7 +53,7 @@ def _postprocess(exp_rows): except ValueError: exp_row[k] = v_str - if not exp_row[k]: + elif not exp_row[k]: exp_row[k] = None return exp_rows diff --git a/tests/func/api/test_experiments.py b/tests/func/api/test_experiments.py index afade043cf..924996f889 100644 --- a/tests/func/api/test_experiments.py +++ b/tests/func/api/test_experiments.py @@ -20,6 +20,8 @@ def test_exp_save(tmp_dir, dvc, scm): def test_exp_show(tmp_dir, dvc, scm, exp_stage): # noqa: F811 + with open("params.yaml", "a") as fobj: + fobj.write("\nbar: 0") exps = api.exp_show() assert len(exps) == 2 @@ -32,3 +34,5 @@ def test_exp_show(tmp_dir, dvc, scm, exp_stage): # noqa: F811 assert exps[0]["State"] is None # Postprocessing empty string as `None` assert exps[0]["Experiment"] is None + # Postprocessing 0 as float + assert exps[0]["bar"] == 0.0