Skip to content

TST: Period with Timestamp overflow #34755

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
Oct 5, 2020
Merged

Conversation

OlivierLuG
Copy link
Contributor

@OlivierLuG OlivierLuG commented Jun 13, 2020

The first part of the test checks that the period inside boundaries does not raise exception when calling start_time and end_time methods. The second part checks that methods raise exceptions when outside of boundaries.
The parameters are Timestamp.min and Timestamp.max, so the tests will follow any change of the boundaries.

)
period.start_time
period.end_time
period = Period(
Copy link
Member

Choose a reason for hiding this comment

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

Could you create a separate test function for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in the last PR

second=bound.second - offset,
freq="us",
)
period.start_time
Copy link
Member

Choose a reason for hiding this comment

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

Would be great to assert what this operation returns. assert period.start_time == ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've tried write a better line for this one, but didn't managed.

@jreback jreback changed the title TST #13346 added tests TST: Period with Timestamp overflow Jun 14, 2020
@jreback jreback added Period Period data type Testing pandas testing functions or related to the test suite labels Jun 14, 2020
@MarcoGorelli
Copy link
Member

Hi @OlivierLuG - is this still active? If so, can you address Matt's comments?

@OlivierLuG
Copy link
Contributor Author

I was sure to made answers... I've made a new PR taking into account @mroeschke review.

@@ -767,6 +768,40 @@ def test_period_deprecated_freq(self):
assert isinstance(p1, Period)
assert isinstance(p2, Period)

def period_constructor(bound, offset):
Copy link
Member

Choose a reason for hiding this comment

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

Maybe just define this in the test since it's only used there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK done

def test_start_time_and_end_time_bounds(self, bound, offset):
# GH #13346
period = TestPeriodProperties.period_constructor(bound, -offset)
assert period.start_time.round(freq="S") == period.to_timestamp().round(
Copy link
Member

Choose a reason for hiding this comment

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

Could you parameterize over start_time and end_time so you can just call getattr(period, time_variable).method(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tests were splitted in two tests test_outter_bounds_start_and_end_time and test_inner_bounds_start_and_end_time with a better parametrization.
Thanks for the tips, I didn't knew about getattr function.

@jreback
Copy link
Contributor

jreback commented Jul 17, 2020

can u merge master and will look

@WillAyd
Copy link
Member

WillAyd commented Sep 30, 2020

@OlivierLuG is this still active?

@OlivierLuG
Copy link
Contributor Author

@OlivierLuG is this still active?

I'm still here. I'll take a look to this PR on sunday.

@jreback jreback added this to the 1.2 milestone Oct 2, 2020
@jreback
Copy link
Contributor

jreback commented Oct 2, 2020

can you merge master, i think a lot has changed since this was last rebase (but it still should pass); ping on green.

@OlivierLuG
Copy link
Contributor Author

OK, done and ping on green

@mroeschke mroeschke merged commit 5541834 into pandas-dev:master Oct 5, 2020
@mroeschke
Copy link
Member

Thanks @OlivierLuG

jbrockmendel pushed a commit to jbrockmendel/pandas that referenced this pull request Oct 13, 2020
* #TST pandas-dev#13346 added tests

* TST pandas-dev#13346 taken review into account

* Added tests for pandas-dev#13346 - with review
kesmit13 pushed a commit to kesmit13/pandas that referenced this pull request Nov 2, 2020
* #TST pandas-dev#13346 added tests

* TST pandas-dev#13346 taken review into account

* Added tests for pandas-dev#13346 - with review
@OlivierLuG OlivierLuG deleted the TST_13346 branch January 2, 2021 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Period Period data type Stale Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pd.Period off by hundred of years for dates past ~2263
6 participants