Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added teststo
utils.py
and fixed bugs (#450)
<!-- Please ensure the PR fulfills the following requirements! --> <!-- If this is your first PR, make sure to add your details to the AUTHORS.rst! --> ### Pull Request Checklist: - [x] This PR addresses an already opened issue (for bug fixes / features) - This PR fixes #xyz - [x] (If applicable) Documentation has been added / updated (for bug fixes / features). - [x] (If applicable) Tests have been added. - [x] This PR does not seem to break the templates. - [ ] CHANGELOG.rst has been updated (with summary of main changes). - [ ] Link to issue (:issue:`number`) and pull request (:pull:`number`) has been added. ### What kind of change does this PR introduce? * Adds tests for all functions located in `utils.py`. With the exception of a few lines impossible to test, everything should be covered. * The `mask` argument in `stack_drop_nans` can now be a list of dimensions. In that case, a `dropna(how='all')` operation will be used to create the mask on-the-fly. * `convert_calendar` in `xs.utils.clean_up` now uses `xarray` instead of `xclim`. * `attrs_to_remove` and `remove_all_attrs_except` in `xs.utils.clean_up` now use real regex. * Smaller changes: * `minimum_calendar` now accepts a list as input. * More calendars are recognized in `translate_time_chunk` * Multiple entries can now be given for `change_attr_prefix` in `xs.utils.clean_up`. * `new_dim` in `unstack_dates` is now None by default and changes depending on the frequency. It becomes `month` if the data is exactly monthly, and keep the old default of `season` otherwise. * Updated the list of libraries in `show_versions` to reflect our current environment. * Bug fixes: * `maybe_unstack` now works if the dimension name is not the default. * `xs.utils.clean_up` now does not also modify the original dataset. * `unstack_dates` now works correctly for yearly datasets when `winter_starts_year=True`. * `unstack_dates` now works correctly for multi-year frequencies. ### Does this PR introduce a breaking change? * `convert_calendar` in `xs.utils.clean_up` now uses `xarray` instead of `xclim`. Keywords aren't compatible between the two, but given that `xclim` will abandon its function, no backwards compatibility was sought. * `attrs_to_remove` and `remove_all_attrs_except` in `xs.utils.clean_up` now use real regex. It should not be too breaking since a `fullmatch()` is used, but `*` is now `.*`. ### Other information: There are 2 lines in `unstack_fill_nan` that I simply don't understand... They will be covered next week when I can talk to the author.
- Loading branch information