Skip to content

Commit

Permalink
api: make exp_show return float instead of None for zeroes
Browse files Browse the repository at this point in the history
  • Loading branch information
dberenbaum authored and dberenbaum committed Oct 30, 2023
1 parent 89b4beb commit fc51477
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dvc/api/experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tests/func/api/test_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit fc51477

Please sign in to comment.