k1lib.fmt module¶
This module is for color formats, units and whatnot. This is exposed automatically with:
from k1lib.imports import *
fmt.txt # exposed
-
k1lib.fmt.
size
(_bytes=0)[source]¶ Formats disk size. Example:
# returns "50.0 bytes" fmt.size(50) # returns "12.0 MB" fmt.size(1.2e7)
-
k1lib.fmt.
sizeOf
(l: Iterator[float]) → Tuple[str, Iterator[float]][source]¶ Figures out appropriate scale, scales back the Iterator, and return both. Example:
x = torch.abs(torch.randn(2)) * 1e4 + 1e5 label, t = fmt.sizeOf(x) # label is "kB" (t | toTensor()).min() # min value should be close to 100
-
k1lib.fmt.
comp
(flop=0)[source]¶ Formats computation amount. Example:
# returns "50.0 FLOPs" fmt.computation(50) # returns "50.0 MFLOPs" fmt.computation(5e7)
-
k1lib.fmt.
compRate
(flops=0)[source]¶ Formats computation rate. Example:
# returns "50.0 FLOPS" fmt.computationRate(50) # returns "50.0 MFLOPS" fmt.computationRate(5e7)
-
k1lib.fmt.
time
(seconds=0)[source]¶ Formats small times. Example:
fmt.time(50) # returns "50.0 s" fmt.time(4000) # returns "4000.0 s" fmt.time(0.02) # returns "20.0 ms" fmt.time(1e-5) # returns "10.0 us"
-
k1lib.fmt.
item
(n=0)[source]¶ Formats generic item. Example:
# returns "50.0" fmt.item(50) # returns "500.0 k" fmt.item(5e5)