-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Empty string as template in CustomPlot.init #841
Changes from 2 commits
554c6ef
41997a6
9ccab9e
374f69c
bf8ff74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,3 +56,57 @@ def test_log_custom_plot_multi_y(tmp_dir): | |
"x_label": "x_label", | ||
"y_label": "y_label", | ||
} | ||
|
||
|
||
def test_log_custom_plot_with_template_as_empty_string(tmp_dir): | ||
live = Live() | ||
out = tmp_dir / live.plots_dir / CustomPlot.subfolder | ||
|
||
datapoints = [{"x": 1, "y": 2}, {"x": 3, "y": 4}] | ||
live.log_plot( | ||
"custom_linear", | ||
datapoints, | ||
x="x", | ||
y="y", | ||
template="", | ||
title="custom_title", | ||
x_label="x_label", | ||
y_label="y_label", | ||
) | ||
|
||
assert json.loads((out / "custom_linear.json").read_text()) == datapoints | ||
# 'template' should not be in plot_config. Default template will be assigned later. | ||
assert live._plots["custom_linear"].plot_config == { | ||
"title": "custom_title", | ||
"x": "x", | ||
"y": "y", | ||
"x_label": "x_label", | ||
"y_label": "y_label", | ||
} | ||
|
||
|
||
def test_default_template_in_log_custom_plot(tmp_dir): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's worth it to add this test, has very less return. We can't test for every combinations. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since |
||
live = Live() | ||
out = tmp_dir / live.plots_dir / CustomPlot.subfolder | ||
|
||
datapoints = [{"x": 1, "y": 2}, {"x": 3, "y": 4}] | ||
live.log_plot( | ||
"custom_linear", | ||
datapoints, | ||
x="x", | ||
y="y", | ||
title="custom_title", | ||
x_label="x_label", | ||
y_label="y_label", | ||
) | ||
|
||
assert json.loads((out / "custom_linear.json").read_text()) == datapoints | ||
|
||
assert live._plots["custom_linear"].plot_config == { | ||
"template": "linear", | ||
"title": "custom_title", | ||
"x": "x", | ||
"y": "y", | ||
"x_label": "x_label", | ||
"y_label": "y_label", | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just disallow empty string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any case, this
template.strip()
is unnecessary.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skshetry Thanks. This is much cleaner.