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

History attribute shows args as kwargs #1018

Merged
merged 7 commits into from Feb 17, 2022
Merged

History attribute shows args as kwargs #1018

merged 7 commits into from Feb 17, 2022

Conversation

aulemahal
Copy link
Collaborator

@aulemahal aulemahal commented Feb 16, 2022

Pull Request Checklist:

  • This PR addresses an already opened issue (for bug fixes / features)
  • Tests for the changes have been added (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • HISTORY.rst has been updated (with summary of main changes)
    • Link to issue (:issue:number) and pull request (:pull:number) has been added.
  • bumpversion patch has been called on this branch
  • The relevant author information has been added to .zenodo.json

What kind of change does this PR introduce?

  • The "history" attribute added by xclim will was changed:
    • The trailing dot was dropped.
    • None inputs are now printed as "None" (and not "<NoneType>").
    • Arguments are always printed as keyword-arguments. This mostly impacts sdba functions, as it was already the case for Indicators.

Example:

from xclim.core.formatting import update_xclim_history
from xclim.testing import open_dataset

@update_xclim_history
def func(da, arg1, arg2=None, arg3=None):
    return da

ds = open_dataset('ERA5/daily_surface_cancities_1990-1993.nc')
out = func(ds.tas, 1, arg2=[2, 2], arg3=None)

print(out.attrs['history'])

Before: [2021-12-20 10:38:35] tas: func(tas, 1, <list>, <NoneType>) - xclim version: 0.32.1.
Now: [2022-02-16 14:58:50] tas: func(da=tas, arg1=1, arg2=<list>, arg3=None) - xclim version: 0.33.2

Does this PR introduce a breaking change?

I guess that it does, if anyone was parsing that string.

…ll_str: None as None - add tests and upd hist
@coveralls
Copy link

coveralls commented Feb 16, 2022

Coverage Status

Coverage increased (+0.009%) to 91.547% when pulling f368b31 on fix-963 into f03d862 on master.

xclim/core/formatting.py Outdated Show resolved Hide resolved
Zeitsperre and others added 3 commits February 17, 2022 09:50
With a fix for the upd_xc_hist test.

Co-authored-by: David Huard <huard.david@ouranos.ca>
Co-authored-by: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com>
@aulemahal aulemahal merged commit c5f40b3 into master Feb 17, 2022
@aulemahal aulemahal deleted the fix-963 branch February 17, 2022 16:08
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.

update_xclim_history misreporting keyword arguments
4 participants