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

Fix dayofweek and dayofyear attributes from dates generated by cftime_range #2633

Merged
merged 5 commits into from
Dec 28, 2018

Conversation

spencerkclark
Copy link
Member

@spencerkclark spencerkclark commented Dec 25, 2018

  • Tests added

It turns out there was a remaining bug in cftime (Unidata/cftime#106) that impacted the results of the dayofwk and dayofyr attributes of cftime objects generated by their replace method, which we use when parsing dates from strings, and in some offset arithmetic.

A workaround is to add a dayofwk=-1 argument to each replace call where the dayofwk or dayofyr would be expected to change. I've fixed this bug upstream in cftime (Unidata/cftime#108), but it will only be available in a future version. Would it be appropriate to use this workaround in xarray?

This would fix this doc page for instance:

screen shot 2018-12-25 at 7 40 30 am

@pep8speaks
Copy link

pep8speaks commented Dec 25, 2018

Hello @spencerkclark! Thanks for updating the PR.

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated on December 26, 2018 at 14:02 Hours UTC

@dcherian
Copy link
Contributor

I think we should include this workaround and plan to bump up the minimum cftime version sometime soon.

@shoyer shoyer merged commit a8e5002 into pydata:master Dec 28, 2018
@shoyer
Copy link
Member

shoyer commented Dec 28, 2018

agreed, thanks!

@spencerkclark spencerkclark deleted the cftime-doy-dow-fix branch December 28, 2018 22:55
dcherian pushed a commit to yohai/xarray that referenced this pull request Jan 2, 2019
* master:
  DEP: drop python 2 support and associated ci mods (pydata#2637)
  TST: silence warnings from bottleneck (pydata#2638)
  revert to dev version
  DOC: fix docstrings and doc build for 0.11.1
  Source encoding always set when opening datasets (pydata#2626)
  Add flake check to travis (pydata#2632)
  Fix dayofweek and dayofyear attributes from dates generated by cftime_range (pydata#2633)
  silence import warning (pydata#2635)
  fill_value in shift (pydata#2470)
  Flake fixed (pydata#2629)
  Allow passing of positional arguments in `apply` for Groupby objects (pydata#2413)
  Fix failure in time encoding for pandas < 0.21.1 (pydata#2630)
  Fix multiindex selection (pydata#2621)
  Close files when CachingFileManager is garbage collected (pydata#2595)
  added some logic to deal with rasterio objects in addition to filepaths (pydata#2589)
  Get 0d slices of ndarrays directly from indexing (pydata#2625)
  FIX Don't raise a deprecation warning for xarray.ufuncs.{angle,iscomplex} (pydata#2615)
  CF: also decode time bounds when available (pydata#2571)
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.

4 participants