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

Remove Tag from Exposures #756

Merged
merged 25 commits into from
Aug 31, 2023
Merged

Conversation

emanuel-schmid
Copy link
Collaborator

@emanuel-schmid emanuel-schmid commented Jul 14, 2023

Changes proposed in this PR:

  • removes tag attribute from Exposures and subclasses
  • introduce new attribute of LitPop: description, which is used in plot_hexbin and plot_scatter to set the title

This PR fixes #

PR Author Checklist

PR Reviewer Checklist

@emanuel-schmid emanuel-schmid changed the title Feature/remove tag exposures Remove Tag from Exposures Jul 14, 2023
Copy link
Member

@peanutfun peanutfun left a comment

Choose a reason for hiding this comment

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

Two minor issues. The rest looks well! 👌

Comment on lines 557 to 558
title = (self.description.strip() if isinstance(self.description, str) else ""
) if title is None else title
Copy link
Member

Choose a reason for hiding this comment

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

title = something if title is None else title seems redundant to me. Also: What other type than str would description support? Should we maybe cast it to str in the constructor to avoid testing its type here?

Suggested change
title = (self.description.strip() if isinstance(self.description, str) else ""
) if title is None else title
if title is None:
title = self.description.strip()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

None is the default. So if you call it with a title-argument - fine, up to you, even if it's an empty string.
If you don't bother - also fine, then the title from the description is plotted.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

your suggestion doesn't work if the description is None. You would need another if block. From there on it's a question of taste I guess.

Copy link
Member

@peanutfun peanutfun Aug 30, 2023

Choose a reason for hiding this comment

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

Then let's keep it as simple as can be: Users need to take care of formatting their descriptions. So I suggest we just do:

Suggested change
title = (self.description.strip() if isinstance(self.description, str) else ""
) if title is None else title
if title is None:
title = self.description

This should also work when description is None, ax.set_title(None) should have no (negative) effect.

Copy link
Collaborator Author

@emanuel-schmid emanuel-schmid Aug 30, 2023

Choose a reason for hiding this comment

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

some util.plot function doesn't like None. Hence I did title = self.description or "".

Comment on lines 624 to 625
title = (self.description.strip() if isinstance(self.description, str) else ""
) if title is None else title
Copy link
Member

Choose a reason for hiding this comment

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

Same as above. title is already assigned to title 😉

Comment on lines 1082 to 1093
if not (
isinstance(decision_dict["probability_aggregation"], float)
& isinstance(decision_dict["area_aggregation"], float)
):
ValueError(
" If decision_level is 'exposure_point',"
+ "parameters probability_aggregation and "
+ "area_aggregation of "
+ "Forecast.plot_warn_map() must both be "
+ "floats between [0..1]. Which each "
+ "specify quantiles."
)
Copy link
Member

Choose a reason for hiding this comment

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

How is this related to the Exposures tag?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not. It's just dead code that has been removed for cosmetic reasons. 🤔 Perhaps better to atctually raise the Error instead?

Copy link
Member

Choose a reason for hiding this comment

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

Forecast will be overhauled anyway. I thinks it's best not to touch that class now. Can you revert the changes, even though the error clearly should be raised? 😅

@emanuel-schmid emanuel-schmid merged commit d9b925c into develop Aug 31, 2023
@emanuel-schmid emanuel-schmid deleted the feature/remove_tag_exposures branch August 31, 2023 06:41
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.

2 participants