Skip to content
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

Use component names for plotting #1783

Merged

Conversation

sudrich
Copy link
Contributor

@sudrich sudrich commented May 18, 2023

Summary

This PR changes TimeSeries.plot() to be in line with its documentation.

Example:

Imagine invoking plot(label="prediction") on a TimeSeries with the labels [A, B, C].

Before the change, the labels are using an enumeration of the components: [prediction_0, prediction_1, prediction_2].
With the change, the labels are using the component names: [prediction_A, prediction_B, prediction_C].

Other Information

The change also allows adding a prefix for a series with a single component. This was not possible for some reason.

Example:

Imagine invoking plot(label="prediction") on a TimeSeries with the labels [A].

Before the change, the label would just be ignored: [A].
With the change, the label is taken into account: [prediction_A].

This behaviour is still possible to recreate by calling plot() or plot(label="").

Copy link
Collaborator

@dennisbader dennisbader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR @sudrich, it looks good.
I had a minor suggestions for using only the label if the series only has a signel component. We could adapt the docstring for label accordingly.

if label == "":
label_to_use = comp_name
else:
label_to_use = f"{label}_{comp_name}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with adding label as a prefix when there are multiple components.
For a single component, I think it's better to overwrite the name with label. WDYT?

Suggested change
label_to_use = f"{label}_{comp_name}"
label_to_use = label if len(self.components) == 1 else f"{label}_{comp_name}"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. I've added it and changed the docstring accordingly.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Collaborator

@dennisbader dennisbader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks @sudrich 🚀
Just had a minor suggestion for rephrasing the docstring :)

Could you resolve the merge conflicts from the recent updates to the CHANGELOG?

darts/timeseries.py Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented May 21, 2023

Codecov Report

Patch coverage: 40.00% and project coverage change: -0.16 ⚠️

Comparison is base (1efb1f8) 94.19% compared to head (fab511e) 94.04%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1783      +/-   ##
==========================================
- Coverage   94.19%   94.04%   -0.16%     
==========================================
  Files         125      125              
  Lines       11505    11495      -10     
==========================================
- Hits        10837    10810      -27     
- Misses        668      685      +17     
Impacted Files Coverage Δ
darts/timeseries.py 92.38% <40.00%> (-0.44%) ⬇️

... and 10 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sudrich sudrich force-pushed the feature/reuse_original_labels_for_plot branch from 933e2aa to 28f1939 Compare May 22, 2023 07:17
Co-authored-by: Dennis Bader <dennis.bader@gmx.ch>
@sudrich sudrich force-pushed the feature/reuse_original_labels_for_plot branch from 28f1939 to fab511e Compare May 22, 2023 07:19
@sudrich
Copy link
Contributor Author

sudrich commented May 22, 2023

Looks good, thanks @sudrich 🚀 Just had a minor suggestion for rephrasing the docstring :)

Could you resolve the merge conflicts from the recent updates to the CHANGELOG?

Thanks for the review. I've addressed the outstanding issue and rebased to master.

Copy link
Collaborator

@dennisbader dennisbader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks a lot @sudrich 💯 🚀

if label == "":
label_to_use = comp_name
else:
label_to_use = f"{label}_{comp_name}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@dennisbader dennisbader merged commit 5b68b69 into unit8co:master May 23, 2023
7 of 9 checks passed
alexcolpitts96 pushed a commit to alexcolpitts96/darts that referenced this pull request May 31, 2023
* Use component names for plotting

* Add changelog entry

* Use label directly for single component series

* Adjust docstring to better reflect changes

Co-authored-by: Dennis Bader <dennis.bader@gmx.ch>

---------

Co-authored-by: Dennis Bader <dennis.bader@gmx.ch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants