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

Tag-Refactoring #736

Merged
merged 39 commits into from
Jun 26, 2023
Merged

Tag-Refactoring #736

merged 39 commits into from
Jun 26, 2023

Conversation

emanuel-schmid
Copy link
Collaborator

Changes proposed in this PR:

  • take haz_type out of Tag and move it to Hazard
  • unify entity.Tag and hazard.Tag to util.Tag

This PR paves the ground for the eventual removal of the tag attributes from all climada classes.

PR Author Checklist

PR Reviewer Checklist

…tag_refactoring

# Conflicts:
#	climada/hazard/test/test_base.py
#	climada/hazard/test/test_storm_europe.py
# Conflicts:
#	climada/entity/exposures/base.py
#	climada/entity/exposures/litpop/litpop.py
Copy link
Member

@chahank chahank left a comment

Choose a reason for hiding this comment

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

Great improvement toward the consolidation of the tag classes. Thanks!

@@ -45,7 +45,6 @@
from rasterio.crs import CRS as rasterioCRS # pylint: disable=no-name-in-module

from climada.entity import Exposures, Tag
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
from climada.entity import Exposures, Tag
from climada.entity import Exposures
from climada.util.tag import Tag

Should it not be like this?

@@ -316,7 +316,8 @@ def from_tracks(
haz.intensity_thres = intensity_thres
LOGGER.debug('Compute frequency.')
haz.frequency_from_tracks(tracks.data)
haz.tag.description = description
haz.tag.append(Tag(description=description))
print('tag tag tag ', haz.tag)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
print('tag tag tag ', haz.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.

oops! 😊

return list_of_str


class Tag():
Copy link
Member

Choose a reason for hiding this comment

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

In another file, there is an equality comparison for tags. Should then the __eq__ not be defined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point! And actually yes, Tag is just the kind of object/class where implementing __eq__ would make a lot of sense, imho.
However - since Tag is to be removed altogether, I guess the effort is not justified.
(The effort of implementing __eq__ may be small enough but finding the places where it can or should be used seems to be serious work.)

Copy link
Member

Choose a reason for hiding this comment

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

I fully agree. I would just remove the equality comparison.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

😲 Er - which equality comparison?

Copy link
Member

Choose a reason for hiding this comment

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

I thought I had seen a tag equality comparison in one file last time I did the review. Unfortunately, I did not write down where, so maybe I was mistaken.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I superficially looked for one but couldn't find it. Shall we remove it when we stumble across?

@emanuel-schmid emanuel-schmid merged commit d6897ae into develop Jun 26, 2023
@emanuel-schmid emanuel-schmid deleted the feature/tag_refactoring branch June 26, 2023 15:06
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