@@ -1042,9 +1042,12 @@ def test_time(self):
1042
1042
for t , l in zip (ticks , labels ):
1043
1043
m , s = divmod (int (t ), 60 )
1044
1044
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' )
1048
1051
assert xp == rs
1049
1052
1050
1053
# change xlim
@@ -1057,9 +1060,12 @@ def test_time(self):
1057
1060
for t , l in zip (ticks , labels ):
1058
1061
m , s = divmod (int (t ), 60 )
1059
1062
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' )
1063
1069
assert xp == rs
1064
1070
1065
1071
@pytest .mark .slow
@@ -1081,13 +1087,19 @@ def test_time_musec(self):
1081
1087
for t , l in zip (ticks , labels ):
1082
1088
m , s = divmod (int (t ), 60 )
1083
1089
1084
- # TODO: unused?
1085
- # us = int((t - int(t)) * 1e6)
1090
+ us = int (round ((t - int (t )) * 1e6 ))
1086
1091
1087
1092
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' )
1091
1103
assert xp == rs
1092
1104
1093
1105
@pytest .mark .slow
0 commit comments