Intelligent scientific notation (.3g). Parameters ---------- n : int or float or Numeric A Number. Returns ------- out : str Formatted number.
(n)
| 418 | |
| 419 | @staticmethod |
| 420 | def format_num(n): |
| 421 | """ |
| 422 | Intelligent scientific notation (.3g). |
| 423 | |
| 424 | Parameters |
| 425 | ---------- |
| 426 | n : int or float or Numeric |
| 427 | A Number. |
| 428 | |
| 429 | Returns |
| 430 | ------- |
| 431 | out : str |
| 432 | Formatted number. |
| 433 | """ |
| 434 | f = f'{n:.3g}'.replace('e+0', 'e+').replace('e-0', 'e-') |
| 435 | n = str(n) |
| 436 | return f if len(f) < len(n) else n |
| 437 | |
| 438 | @staticmethod |
| 439 | def status_printer(file): |