Function that converts a number to his version with SI prefix @input value (an integer) @example: >>> add_si_prefix(10000) '10.0 kilo'
(value: float)
| 85 | |
| 86 | |
| 87 | def add_si_prefix(value: float) -> str: |
| 88 | """ |
| 89 | Function that converts a number to his version with SI prefix |
| 90 | @input value (an integer) |
| 91 | @example: |
| 92 | >>> add_si_prefix(10000) |
| 93 | '10.0 kilo' |
| 94 | """ |
| 95 | prefixes = SIUnit.get_positive() if value > 0 else SIUnit.get_negative() |
| 96 | for name_prefix, value_prefix in prefixes.items(): |
| 97 | numerical_part = value / (10**value_prefix) |
| 98 | if numerical_part > 1: |
| 99 | return f"{numerical_part!s} {name_prefix}" |
| 100 | return str(value) |
| 101 | |
| 102 | |
| 103 | def add_binary_prefix(value: float) -> str: |
nothing calls this directly
no test coverage detected