Skip to content

Commit 08884b2

Browse files
committed
fixed tests to match English grammar
1 parent 5f9bf52 commit 08884b2

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

codeflash/code_utils/time_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ def humanize_runtime(time_in_ns: int) -> str:
3030
runtime_human = "%.3g" % (time_micro / (24*3600 * 1000**2))
3131
runtime_human_parts = str(runtime_human).split(".")
3232
if len(runtime_human_parts[0]) == 1:
33+
if runtime_human_parts[0]=='1' and len(runtime_human_parts)>1:
34+
units = units+'s'
3335
if len(runtime_human_parts) == 1:
3436
runtime_human = f"{runtime_human_parts[0]}.00"
3537
elif len(runtime_human_parts[1]) >= 2:

tests/test_humanize_time.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,23 @@ def test_humanize_runtime():
88
assert humanize_runtime(1000000000) == "1.00 second"
99
assert humanize_runtime(60000000000) == "1.00 minute"
1010
assert humanize_runtime(3600000000000) == "1.00 hour"
11+
assert humanize_runtime(86400000000000) == "1.00 day"
1112

1213
assert humanize_runtime(1) == "1.00 nanosecond"
1314
assert humanize_runtime(12) == "12.0 nanoseconds"
1415
assert humanize_runtime(123) == "123 nanoseconds"
1516
assert humanize_runtime(999) == "999 nanoseconds"
16-
assert humanize_runtime(1234) == "1.23 microsecond"
17+
assert humanize_runtime(1234) == "1.23 microseconds"
1718
assert humanize_runtime(12345) == "12.3 microseconds"
1819
assert humanize_runtime(123456) == "123 microseconds"
19-
assert humanize_runtime(1234567) == "1.23 millisecond"
20+
assert humanize_runtime(1234567) == "1.23 milliseconds"
2021
assert humanize_runtime(12345678) == "12.3 milliseconds"
2122
assert humanize_runtime(123456789) == "123 milliseconds"
2223

23-
assert humanize_runtime(1234567891) == "1.23 second"
24+
assert humanize_runtime(1234567891) == "1.23 seconds"
2425
assert humanize_runtime(12345678912) == "12.3 seconds"
2526
assert humanize_runtime(123456789123) == "2.06 minutes"
2627
assert humanize_runtime(1234567891234) == "20.6 minutes"
2728
assert humanize_runtime(12345678912345) == "3.43 hours"
28-
assert humanize_runtime(98765431298760) == "1.14 day"
29+
assert humanize_runtime(98765431298760) == "1.14 days"
2930
assert humanize_runtime(197530862597520) == "2.29 days"

0 commit comments

Comments
 (0)