Skip to content

Commit 200528b

Browse files
committed
test_datetimelike::test_time: update expected results
1 parent a64eec1 commit 200528b

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
@@ -1043,9 +1043,12 @@ def test_time(self):
10431043
for t, l in zip(ticks, labels):
10441044
m, s = divmod(int(t), 60)
10451045
h, m = divmod(m, 60)
1046-
xp = l.get_text()
1047-
if len(xp) > 0:
1048-
rs = time(h, m, s).strftime('%H:%M:%S')
1046+
rs = l.get_text()
1047+
if len(rs) > 0:
1048+
if s != 0:
1049+
xp = time(h, m, s).strftime('%H:%M:%S')
1050+
else:
1051+
xp = time(h, m, s).strftime('%H:%M')
10491052
assert xp == rs
10501053

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

10661072
@pytest.mark.slow
@@ -1082,13 +1088,19 @@ def test_time_musec(self):
10821088
for t, l in zip(ticks, labels):
10831089
m, s = divmod(int(t), 60)
10841090

1085-
# TODO: unused?
1086-
# us = int((t - int(t)) * 1e6)
1091+
us = int(round((t - int(t)) * 1e6))
10871092

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

10941106
@pytest.mark.slow

0 commit comments

Comments
 (0)