Skip to content

Fix bugs in WeekOfMonth.apply, Week.onOffset #18875

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

Merged
merged 5 commits into from
Dec 23, 2017

Conversation

jbrockmendel
Copy link
Member

@jbrockmendel jbrockmendel commented Dec 20, 2017

In the process we get rid of WeekOfMonth.getOffsetOfMonth and LastWeekOfMonth.getOffsetOfMonth, which were idiosyncratic what arguments they passed to datetime.

The issues this addresses are orthogonal to #18762, but the code affected does overlap. In particular, after this, roll_monthday will not be needed in 18762.

closes #18864
closes #18672
closes #18510

  • tests added / passed
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

comments. looks good after changes. ping on green.

@@ -362,3 +362,4 @@ Other

- Improved error message when attempting to use a Python keyword as an identifier in a ``numexpr`` backed query (:issue:`18221`)
- Bug in :class:`Timestamp` where comparison with an array of ``Timestamp`` objects would result in a ``RecursionError`` (:issue:`15183`)
Copy link
Contributor

Choose a reason for hiding this comment

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

pls move both this and the one higher to conversion. pls dont' put things in Other that fit elsewhere.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK. Out of curiosity, what is the heuristic that gets this lumped into "conversion"?

tz = other.tzinfo
naive = other.replace(tzinfo=None)
shifted = naive + timedelta(days=days)
return tslib._localize_pydatetime(shifted, tz)
Copy link
Contributor

Choose a reason for hiding this comment

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

side issue. _localize_pydatetime is in the wrong place (its in tslib) should be in conversion.pyx. And It shouldn't just return on None as well, and needs a better doc-string. can you add to list.

d = datetime(dt.year, dt.month, dt.day, tzinfo=dt.tzinfo)
return d == self.getOffsetOfMonth(dt)
def _get_offset_day(self, other):
mstart = datetime(other.year, other.month, 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you document

return False
return dt == self.getOffsetOfMonth(dt)
def _get_offset_day(self, other):
dim = ccalendar.get_days_in_month(other.year, other.month)
Copy link
Contributor

Choose a reason for hiding this comment

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

same

@@ -362,3 +362,4 @@ Other

- Improved error message when attempting to use a Python keyword as an identifier in a ``numexpr`` backed query (:issue:`18221`)
- Bug in :class:`Timestamp` where comparison with an array of ``Timestamp`` objects would result in a ``RecursionError`` (:issue:`15183`)
- Bug in :class:`WeekOfMonth` and class:`Week` where addition and subtraction did not roll correctly (:issue:`18672`,:issue:`18510`)
Copy link
Contributor

Choose a reason for hiding this comment

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

there is a 3rd issue no?

@jreback jreback added this to the 0.23.0 milestone Dec 21, 2017
@codecov
Copy link

codecov bot commented Dec 21, 2017

Codecov Report

Merging #18875 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #18875      +/-   ##
==========================================
- Coverage   91.65%   91.64%   -0.01%     
==========================================
  Files         154      154              
  Lines       51368    51364       -4     
==========================================
- Hits        47080    47074       -6     
- Misses       4288     4290       +2
Flag Coverage Δ
#multiple 89.51% <100%> (-0.01%) ⬇️
#single 40.84% <21.62%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/tseries/offsets.py 96.78% <100%> (-0.17%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 316acbf...e71374f. Read the comment docs.

@jbrockmendel
Copy link
Member Author

Ping

@jreback jreback merged commit 175cc4f into pandas-dev:master Dec 23, 2017
@jreback
Copy link
Contributor

jreback commented Dec 23, 2017

thanks!

@jbrockmendel jbrockmendel mentioned this pull request Dec 29, 2017
39 tasks
@jbrockmendel jbrockmendel deleted the offsets-fixweeks branch February 11, 2018 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frequency DateOffsets
Projects
None yet
2 participants