Skip to content

Commit 4de8f3c

Browse files
committed
value error fix
1 parent 606889e commit 4de8f3c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

codeflash/code_utils/time_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ def humanize_runtime(time_in_ns: int) -> str:
5454
def format_time(nanoseconds: int) -> str:
5555
"""Format nanoseconds into a human-readable string with 3 significant digits when needed."""
5656
# Define conversion factors and units
57-
if type(nanoseconds) is not int:
57+
if type(nanoseconds):
5858
raise TypeError("Input must be an integer.")
59+
if nanoseconds < 0:
60+
raise ValueError("Input must be a positive integer.")
5961
conversions = [(1_000_000_000, "s"), (1_000_000, "ms"), (1_000, "μs"), (1, "ns")]
6062

6163
# Handle nanoseconds case directly (no decimal formatting needed)

0 commit comments

Comments
 (0)