-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Continue porting period_helper; fix leftover asfreq bug #19834
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok except for the catching the RunTimewarning on localize. easiest prob to remove and do that next pass
@@ -28,15 +28,17 @@ def test_tz_localize_pushes_out_of_bounds(self): | |||
pac = Timestamp.min.tz_localize('US/Pacific') | |||
assert pac.value > Timestamp.min.value | |||
pac.tz_convert('Asia/Tokyo') # tz_convert doesn't change value | |||
with pytest.raises(OutOfBoundsDatetime): | |||
Timestamp.min.tz_localize('Asia/Tokyo') | |||
with tm.assert_produces_warning(RuntimeWarning): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a missing check in localize itself, IOW need to check if something is 0
@@ -21,6 +21,16 @@ def test_asfreq_near_zero(self, freq): | |||
tup2 = (prev.year, prev.month, prev.day) | |||
assert tup2 < tup1 | |||
|
|||
def test_asfreq_near_zero_weekly(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can rename to test_asfreq?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name follows convention set by the test above it (test_asfreq_near_zero
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean the module name itself.
sure |
Codecov Report
@@ Coverage Diff @@
## master #19834 +/- ##
=======================================
Coverage 91.58% 91.58%
=======================================
Files 150 150
Lines 48890 48890
=======================================
Hits 44775 44775
Misses 4115 4115
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename, ping on green.
@@ -21,6 +21,16 @@ def test_asfreq_near_zero(self, freq): | |||
tup2 = (prev.year, prev.month, prev.day) | |||
assert tup2 < tup1 | |||
|
|||
def test_asfreq_near_zero_weekly(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean the module name itself.
That makes much more sense. Mind waiting for the next pass since appveyor has a 12hour+ turnaround? |
ok |
In #19650 we fixed a bug with asfreq but missed a weekly-frequency case. This fixes and tests that. I'll see if I can cook up a more thorough set of tests to make sure nothing else slips through the cracks.
Other than that, the main thing this does is substitute in
ORD_OFFSET = WEEK_OFFSET * 7 + 4
andBDAY_OFFSET = 5 * WEEK_OFFSET + 4
and then cleans up some algebra (which is now OK because we are using non-cdivision floordiv and mod). As a result we get rid of a bunch of calls that add ORD_OFFSET just to subtract it a few lines later.Gets rid of CamelCase in tslibs.period, moves towards using pandas_datetimestruct directly and getting rid of the redundant
date_info
.Catches a RuntimeWarning in the tests; closes #19767.