-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: Parameterize test case #22327
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
CLN: Parameterize test case #22327
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,26 +19,19 @@ class TestTimestampUnaryOps(object): | |
|
||
# -------------------------------------------------------------- | ||
# Timestamp.round | ||
|
||
def test_round_day_naive(self): | ||
dt = Timestamp('20130101 09:10:11') | ||
result = dt.round('D') | ||
expected = Timestamp('20130101') | ||
assert result == expected | ||
|
||
dt = Timestamp('20130101 19:10:11') | ||
result = dt.round('D') | ||
expected = Timestamp('20130102') | ||
assert result == expected | ||
|
||
dt = Timestamp('20130201 12:00:00') | ||
result = dt.round('D') | ||
expected = Timestamp('20130202') | ||
assert result == expected | ||
|
||
dt = Timestamp('20130104 12:00:00') | ||
result = dt.round('D') | ||
expected = Timestamp('20130105') | ||
@pytest.mark.parametrize('timestamp_input, round_freq, date', [ | ||
('20130101 09:10:11', 'D', '20130101'), | ||
('20130101 19:10:11', 'D', '20130102'), | ||
('20130201 12:00:00', 'D', '20130202'), | ||
('20130104 12:00:00', 'D', '20130105'), | ||
('2000-01-05 05:09:15.13', 'D', '2000-01-05 00:00:00'), | ||
('2000-01-05 05:09:15.13', 'H', '2000-01-05 05:00:00'), | ||
('2000-01-05 05:09:15.13', 'S', '2000-01-05 05:09:15') | ||
]) | ||
def test_round_frequencies(self, timestamp_input, round_freq, date): | ||
dt = Timestamp(timestamp_input) | ||
result = dt.round(round_freq) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By nature of this test I suppose we don't really need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for taking a look @WillAyd , turns out there was another similar test function in the same file so I combined them. What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! Just one more minor nit looks like your test is called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh my bad.. thanks have done! |
||
expected = Timestamp(date) | ||
assert result == expected | ||
|
||
def test_round_tzaware(self): | ||
|
@@ -85,16 +78,6 @@ def test_round_invalid_arg(self): | |
with tm.assert_raises_regex(ValueError, INVALID_FREQ_ERR_MSG): | ||
stamp.round('foo') | ||
|
||
@pytest.mark.parametrize('freq, expected', [ | ||
('D', Timestamp('2000-01-05 00:00:00')), | ||
('H', Timestamp('2000-01-05 05:00:00')), | ||
('S', Timestamp('2000-01-05 05:09:15'))]) | ||
def test_round_frequencies(self, freq, expected): | ||
stamp = Timestamp('2000-01-05 05:09:15.13') | ||
|
||
result = stamp.round(freq=freq) | ||
assert result == expected | ||
|
||
@pytest.mark.parametrize('test_input, rounder, freq, expected', [ | ||
('2117-01-01 00:00:45', 'floor', '15s', '2117-01-01 00:00:45'), | ||
('2117-01-01 00:00:45', 'ceil', '15s', '2117-01-01 00:00:45'), | ||
|
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.
just call this
timestamp, freq, expected
for the args, otherwise lgtm.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.
thanks @jreback updated