Skip to content

remove tag from Exposures#89

Merged
emanuel-schmid merged 6 commits intodevelopfrom
feature/remove_tag_exposures
Aug 29, 2023
Merged

remove tag from Exposures#89
emanuel-schmid merged 6 commits intodevelopfrom
feature/remove_tag_exposures

Conversation

@emanuel-schmid
Copy link
Copy Markdown
Contributor

@emanuel-schmid emanuel-schmid commented Aug 9, 2023

Changes proposed in this PR:

  • Remove all tag occurrences from exposures classes

This PR fixes #

PR Author Checklist

PR Reviewer Checklist

data=Exposures.concat(bkmrbl_list).gdf,
crs=DEF_CRS,
ref_year=ref_year,
tag=Tag(file_name=fn_nl, description=description),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also in line 36 above we can remove the import.

Copy link
Copy Markdown
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.

Small comments only, otherwise good, thanks!

self,
data=Exposures.concat(gdp2a_list).gdf,
ref_year=ref_year,
tag=Tag(description=description),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The tag import in line 31 can be remove I think.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out!

- ipython
- ipykernel
- mccabe>=0.6
- nb_conda
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a bit unrelated to this PR imho. Why is this necessary for the tag removal?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, this is only for making readthedocs run again. It's now in develop as well.

@emanuel-schmid
Copy link
Copy Markdown
Contributor Author

Eventually it turned out to be a bit more complicated than hoped for. Three exposures classes in petals actually do store information about how the dataset was constructed in the tag's description. This information is shown in the exposures plots and to me doesn't see to be completely useless. Furthermore the datasets from the API seem to have contain information in the tags that I'm not sure is available otherwise.
So I decided to keep the description - for the time being - as an attribute, not just for LitPop but for all Exposures classes.

Besides I also kept the raw data files for BlackMarble and SpamAgrar, not as file_name but as nightlight_file and spam_file respectively, because the identification of the suitable file is part of the creation process and not provided by the user.

🤷

@chahank
Copy link
Copy Markdown
Member

chahank commented Aug 14, 2023

I think we should get rid of these description elements unless we are able to make a stable and useful solution. The information in the plots are almost always not necessary. Concerning the data API, I would say it is a bad practice if relevant information is hidden in the attribute of a file instead of being part of the metadata of the file in the database. Thus, I would again argue for removing the description rather than keeping it.

@emanuel-schmid
Copy link
Copy Markdown
Contributor Author

As far as I'm concerned I agree, but whether something is useful or not is in the eye of the beholder.
You say the information in the plots is almost always not necessary - sounds to me like exceptionally they may benecessary.

Concerning the data API: fully agreed that is bad practice. But in case it was ever applied, we would need to replace the concerned datasets in a rather elaborate procedure that involves the api_client.Client from climada 3.x - or rebuild them from scratch.

On the other side: having a description attribute in the Exposures class looks quite harmless to me. There is an arbitrary string in the class obviously containing a description of the object - so what? And if it shows up in plots - all the better!
Is it useful? s.a. Is it stable? Stable enough I'd say.

@peanutfun peanutfun mentioned this pull request Aug 21, 2023
13 tasks
Copy link
Copy Markdown
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.

We should make description a "regular" attribute of the exposure classes that use it, and document it accordingly. Other than that, all looks fine.

Thank you for improving the tests by using better asserts than assertTrue, this is much better! 🙌

Comment on lines +365 to +367
exp.description=("Crop production exposure from ISIMIP"
f" {CROP_NAME[crop]['print']} {irr}"
f" {yearrange[0]} {yearrange[-1]}")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Similar topic: I find it bad practise to set an attribute that is not defined in the constructor. (I know that Exposures combines several bad practices when it comes to constructors but we don't have to make it worse)

The description attribute is also never documented anywhere.

@emanuel-schmid emanuel-schmid merged commit 42329d8 into develop Aug 29, 2023
@emanuel-schmid emanuel-schmid deleted the feature/remove_tag_exposures branch August 29, 2023 05:38
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.

3 participants