-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
live.log_metric: Cast
nan
and inf
to string.
- Support string metrics (forgot to support them when DVC added support) - Don't recast to float when sending to Studio. Closes iterative/studio-support#93
- Loading branch information
Showing
4 changed files
with
34 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import math | ||
|
||
import numpy as np | ||
import pytest | ||
|
||
from dvclive import Live | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("val"), | ||
[math.inf, math.nan, np.nan, np.inf], | ||
) | ||
def test_log_metric_inf_nan(tmp_dir, val): | ||
with Live() as live: | ||
live.log_metric("metric", val) | ||
assert live.summary["metric"] == str(val) | ||
|
||
|
||
def test_log_metic_str(tmp_dir): | ||
with Live() as live: | ||
live.log_metric("metric", "foo") | ||
assert live.summary["metric"] == "foo" |