Skip to content

Commit e0aadac

Browse files
committed
Minor fixes in index and scalar tests
1 parent 0a6eecd commit e0aadac

File tree

2 files changed

+31
-30
lines changed

2 files changed

+31
-30
lines changed

pandas/tests/indexes/datetimes/test_ops.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,13 @@ def test_numpy_minmax(self):
168168
('1823-01-01 00:00:01.000000012', 'ceil', '10ns',
169169
'1823-01-01 00:00:01.000000020')
170170
])
171-
# @pytest.mark.parametrize('tz', tz)
172-
def test_round_ops(self, test_input, rounder, freq, expected):
173-
for tz in self.tz:
174-
index = pd.DatetimeIndex([test_input], tz=tz)
175-
func = getattr(index, rounder)
176-
result = func(freq)
177-
expect = pd.DatetimeIndex([expected], tz=tz)
178-
tm.assert_index_equal(result, expect)
171+
@pytest.mark.parametrize('tz', tz)
172+
def test_round_ops(self, test_input, rounder, freq, expected, tz):
173+
index = pd.DatetimeIndex([test_input], tz=tz)
174+
func = getattr(index, rounder)
175+
result = func(freq)
176+
expect = pd.DatetimeIndex([expected], tz=tz)
177+
tm.assert_index_equal(result, expect)
179178

180179
def test_round_daily(self):
181180
dti = pd.date_range('20130101 09:10:11', periods=5)

pandas/tests/scalar/test_timestamp.py

+24-22
Original file line numberDiff line numberDiff line change
@@ -745,46 +745,48 @@ def test_to_pydatetime_nonzero_nano(self):
745745
assert result == expected
746746

747747
@pytest.mark.parametrize('test_input, rounder, freq, expected, kw', [
748-
('20130101 09:10:11', 'floor', 'D', '20130101', {}),
748+
('20130101 09:10:11', 'floor', 'D', '20130101', None),
749749
# GH 19206 - times far in the future and past rounding incorrectly
750-
('2117-01-01 00:00:45', 'floor', '15s', '2117-01-01 00:00:45', {}),
751-
('2117-01-01 00:00:45', 'ceil', '15s', '2117-01-01 00:00:45', {}),
750+
('2117-01-01 00:00:45', 'floor', '15s', '2117-01-01 00:00:45', None),
751+
('2117-01-01 00:00:45', 'ceil', '15s', '2117-01-01 00:00:45', None),
752752
('2117-01-01 00:00:45.000000012', 'floor', '10ns',
753-
'2117-01-01 00:00:45.000000010', {}),
754-
('1823-01-01 00:00:01', 'floor', '1s', '1823-01-01 00:00:01', {}),
755-
('1823-01-01 00:00:01', 'ceil', '1s', '1823-01-01 00:00:01', {}),
753+
'2117-01-01 00:00:45.000000010', None),
754+
('1823-01-01 00:00:01', 'floor', '1s', '1823-01-01 00:00:01', None),
755+
('1823-01-01 00:00:01', 'ceil', '1s', '1823-01-01 00:00:01', None),
756756
('1823-01-01 00:00:01.000000012', 'floor', '10ns',
757-
'1823-01-01 00:00:01.000000010', {}),
757+
'1823-01-01 00:00:01.000000010', None),
758758
('1823-01-01 00:00:01.000000012', 'ceil', '10ns',
759-
'1823-01-01 00:00:01.000000020', {}),
759+
'1823-01-01 00:00:01.000000020', None),
760760
# ----
761-
('20130101 09:10:11', 'ceil', 'D', '20130102', {}),
762-
('20130101 09:10:11', 'round', 'D', '20130101', {}),
763-
('20130101 19:10:11', 'round', 'D', '20130102', {}),
764-
('20130201 12:00:00', 'round', 'D', '20130202', {}),
765-
('20130104 12:00:00', 'round', 'D', '20130105', {}),
766-
('20130104 12:32:00', 'round', '30Min', '20130104 12:30:00', {}),
761+
('20130101 09:10:11', 'ceil', 'D', '20130102', None),
762+
('20130101 09:10:11', 'round', 'D', '20130101', None),
763+
('20130101 19:10:11', 'round', 'D', '20130102', None),
764+
('20130201 12:00:00', 'round', 'D', '20130202', None),
765+
('20130104 12:00:00', 'round', 'D', '20130105', None),
766+
('20130104 12:32:00', 'round', '30Min', '20130104 12:30:00', None),
767767
# round with tz
768768
('20130101 09:10:11', 'round', 'D', '20130101', {'tz': 'US/Eastern'}),
769769
('20130101 09:10:11', 'round', 's', '20130101 09:10:11',
770770
{'tz': 'US/Eastern'}),
771771
# GH 14440 & 15578
772772
('2016-10-17 12:00:00.0015', 'round', 'ms',
773-
'2016-10-17 12:00:00.002000', {}),
773+
'2016-10-17 12:00:00.002000', None),
774774
('2016-10-17 12:00:00.00149', 'round', 'ms',
775-
'2016-10-17 12:00:00.001000', {}),
775+
'2016-10-17 12:00:00.001000', None),
776776
('2016-10-17 12:00:00.0015', 'round', 'us',
777-
'2016-10-17 12:00:00.0015', {}),
777+
'2016-10-17 12:00:00.0015', None),
778778
('2016-10-17 12:00:00.0015', 'round', 'ns',
779-
'2016-10-17 12:00:00.0015', {}),
779+
'2016-10-17 12:00:00.0015', None),
780780
('2016-10-17 12:00:00.001501031', 'round', '10ns',
781-
'2016-10-17 12:00:00.001501030', {}),
782-
('2000-01-05 05:09:15.13', 'round', 'D', '2000-01-05 00:00:00', {}),
783-
('2000-01-05 05:09:15.13', 'round', 'H', '2000-01-05 05:00:00', {}),
784-
('2000-01-05 05:09:15.13', 'round', 'S', '2000-01-05 05:09:15', {})
781+
'2016-10-17 12:00:00.001501030', None),
782+
('2000-01-05 05:09:15.13', 'round', 'D', '2000-01-05 00:00:00', None),
783+
('2000-01-05 05:09:15.13', 'round', 'H', '2000-01-05 05:00:00', None),
784+
('2000-01-05 05:09:15.13', 'round', 'S', '2000-01-05 05:09:15', None)
785785
786786
])
787787
def test_round_timestamp(self, test_input, rounder, freq, expected, kw):
788+
if kw is None:
789+
kw = {}
788790
dt = Timestamp(test_input, **kw)
789791
func = getattr(dt, rounder)
790792
result = func(freq)

0 commit comments

Comments
 (0)