Skip to content

Commit 9b8bde4

Browse files
committed
test_datetimelike::test_time: update expected results
1 parent 75ae4f1 commit 9b8bde4

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

pandas/tests/plotting/test_datetimelike.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,9 +1042,12 @@ def test_time(self):
10421042
for t, l in zip(ticks, labels):
10431043
m, s = divmod(int(t), 60)
10441044
h, m = divmod(m, 60)
1045-
xp = l.get_text()
1046-
if len(xp) > 0:
1047-
rs = time(h, m, s).strftime('%H:%M:%S')
1045+
rs = l.get_text()
1046+
if len(rs) > 0:
1047+
if s != 0:
1048+
xp = time(h, m, s).strftime('%H:%M:%S')
1049+
else:
1050+
xp = time(h, m, s).strftime('%H:%M')
10481051
assert xp == rs
10491052

10501053
# change xlim
@@ -1057,9 +1060,12 @@ def test_time(self):
10571060
for t, l in zip(ticks, labels):
10581061
m, s = divmod(int(t), 60)
10591062
h, m = divmod(m, 60)
1060-
xp = l.get_text()
1061-
if len(xp) > 0:
1062-
rs = time(h, m, s).strftime('%H:%M:%S')
1063+
rs = l.get_text()
1064+
if len(rs) > 0:
1065+
if s != 0:
1066+
xp = time(h, m, s).strftime('%H:%M:%S')
1067+
else:
1068+
xp = time(h, m, s).strftime('%H:%M')
10631069
assert xp == rs
10641070

10651071
@pytest.mark.slow
@@ -1081,13 +1087,19 @@ def test_time_musec(self):
10811087
for t, l in zip(ticks, labels):
10821088
m, s = divmod(int(t), 60)
10831089

1084-
# TODO: unused?
1085-
# us = int((t - int(t)) * 1e6)
1090+
us = int(round((t - int(t)) * 1e6))
10861091

10871092
h, m = divmod(m, 60)
1088-
xp = l.get_text()
1089-
if len(xp) > 0:
1090-
rs = time(h, m, s).strftime('%H:%M:%S.%f')
1093+
rs = l.get_text()
1094+
if len(rs) > 0:
1095+
if (us % 1000) != 0:
1096+
xp = time(h, m, s, us).strftime('%H:%M:%S.%f')
1097+
elif (us // 1000) != 0:
1098+
xp = time(h, m, s, us).strftime('%H:%M:%S.%f')[:-3]
1099+
elif s != 0:
1100+
xp = time(h, m, s, us).strftime('%H:%M:%S')
1101+
else:
1102+
xp = time(h, m, s, us).strftime('%H:%M')
10911103
assert xp == rs
10921104

10931105
@pytest.mark.slow

0 commit comments

Comments
 (0)